Use fast exceptions in findResource(s)

Some libraries like aspectj are using findResource to see the raw
bytecode of a class. It will even call findResource for every method of
every class of beans that are post processed. This can be significant
performance hit on startup when LaunchedURLClassLoader and there are a
lot of nested jars.

See gh-3640
Fixes gh-4557
pull/4626/merge
Vladimir Tsanev 9 years ago committed by Stephane Nicoll
parent 1adca44eaa
commit 1e2f133892

@ -82,8 +82,14 @@ public class LaunchedURLClassLoader extends URLClassLoader {
if (name.equals("") && hasURLs()) {
return getURLs()[0];
}
Handler.setUseFastConnectionExceptions(true);
try {
return super.findResource(name);
}
finally {
Handler.setUseFastConnectionExceptions(false);
}
}
catch (IllegalArgumentException ex) {
return null;
}
@ -94,8 +100,14 @@ public class LaunchedURLClassLoader extends URLClassLoader {
if (name.equals("") && hasURLs()) {
return Collections.enumeration(Arrays.asList(getURLs()));
}
Handler.setUseFastConnectionExceptions(true);
try {
return super.findResources(name);
}
finally {
Handler.setUseFastConnectionExceptions(false);
}
}
private boolean hasURLs() {
return getURLs().length > 0;
@ -291,6 +303,6 @@ public class LaunchedURLClassLoader extends URLClassLoader {
return this.localResources.nextElement();
}
};
}
}

Loading…
Cancel
Save