Skip to content

Commit

Permalink
bug: websphere deploy war (#9918)
Browse files Browse the repository at this point in the history
see: #9906
  • Loading branch information
sdelamo authored Sep 26, 2023
1 parent d4df928 commit ab00434
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
3 changes: 2 additions & 1 deletion core/src/main/java/io/micronaut/core/io/IOUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class IOUtils {
private static final String SCHEME_FILE = "file";
private static final String SCHEME_JAR = "jar";
private static final String SCHEME_ZIP = "zip";
private static final String SCHEME_WSJAR = "wsjar";

private static final String COLON = ":";

Expand Down Expand Up @@ -143,7 +144,7 @@ static Path resolvePath(@NonNull URI uri,
IOExceptionBiFunction<List<Closeable>, String, Path> loadNestedJarUriFunction) throws IOException {
String scheme = uri.getScheme();
try {
if (SCHEME_JAR.equals(scheme) || SCHEME_ZIP.equals(scheme)) {
if (SCHEME_JAR.equals(scheme) || SCHEME_ZIP.equals(scheme) || SCHEME_WSJAR.equals(scheme)) {
// try to match FileSystems.newFileSystem(URI) semantics for zipfs here.
// Basically ignores anything after the !/ if it exists, and uses the part
// before as the jar path to extract.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,28 @@ private Set<String> computeStandardServiceTypeNames(URL url) {
return typeNames;
}

private boolean isWebSphereClassLoader() {
return classLoader.getClass().getName().startsWith("com.ibm.ws.classloader");
}

private String buildResourceSearchPath() {
String path = "META-INF/micronaut/" + serviceName;

if (isWebSphereClassLoader()) {
// Special case WebSphere classloader
// https://github.com/micronaut-projects/micronaut-core/issues/9905
return path + "/";
}

return path;
}

private Enumeration<URL> findStandardServiceConfigs() throws IOException {
return classLoader.getResources(SoftServiceLoader.META_INF_SERVICES + '/' + serviceName);
}

private void findMicronautMetaServiceConfigs(BiConsumer<URI, String> consumer) throws IOException, URISyntaxException {
final String path = "META-INF/micronaut/" + serviceName;
String path = buildResourceSearchPath();
final Enumeration<URL> micronautResources = classLoader.getResources(path);
Set<URI> uniqueURIs = new LinkedHashSet<>();
while (micronautResources.hasMoreElements()) {
Expand Down
3 changes: 3 additions & 0 deletions core/src/test/groovy/io/micronaut/core/io/IOUtilsSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ class IOUtilsSpec extends Specification {
"META-INF/micronaut/io.micronaut.inject.BeanConfiguration" | "/META-INF/micronaut/io.micronaut.inject.BeanConfiguration" | "jar:file:/Users/sdelamo/.m2/repository/io/micronaut/micronaut-jackson-databind/3.5.7/micronaut-jackson-databind-3.5.7.jar!/META-INF/micronaut/io.micronaut.inject.BeanConfiguration"
"META-INF/micronaut/io.micronaut.inject.BeanConfiguration" | "/META-INF/micronaut/io.micronaut.inject.BeanConfiguration" | "zip:/u01/oracle/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/issue8386-0.1/y2p3pa/war/WEB-INF/lib/micronaut-jackson-databind-3.5.7.jar!/META-INF/micronaut/io.micronaut.inject.BeanConfiguration/"
"META-INF/micronaut/io.micronaut.inject.BeanConfiguration" | "/META-INF/micronaut/io.micronaut.inject.BeanConfiguration" | "zip:C:/oracle/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/issue8386-0.1/y2p3pa/war/WEB-INF/lib/micronaut-jackson-databind-3.5.7.jar!/META-INF/micronaut/io.micronaut.inject.BeanConfiguration/"
"META-INF/micronaut/io.micronaut.inject.BeanDefinitionReference" | "/META-INF/micronaut/io.micronaut.inject.BeanDefinitionReference" | "wsjar:file:/path/to/io/micronaut/micronaut-json-core/3.5.7/micronaut-json-core-3.5.7.jar!/META-INF/micronaut/io.micronaut.inject.BeanDefinitionReference"
"META-INF/micronaut/io.micronaut.inject.BeanConfiguration" | "/META-INF/micronaut/io.micronaut.inject.BeanConfiguration" | "wsjar:/path/to/io/micronaut/micronaut-jackson-databind/3.5.7/micronaut-jackson-databind-3.5.7.jar!/META-INF/micronaut/io.micronaut.inject.BeanConfiguration"
"META-INF/micronaut/io.micronaut.inject.BeanConfiguration" | "/META-INF/micronaut/io.micronaut.inject.BeanConfiguration" | "wsjar:C:/path/to/io/micronaut/micronaut-jackson-databind/3.5.7/micronaut-jackson-databind-3.5.7.jar!/META-INF/micronaut/io.micronaut.inject.BeanConfiguration"
}

void "resolvePath will fix jar uri on Windows/WebLogic"() {
Expand Down

0 comments on commit ab00434

Please sign in to comment.