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
This commit is contained in:
committed by
Stephane Nicoll
parent
1adca44eaa
commit
1e2f133892
@@ -82,7 +82,13 @@ public class LaunchedURLClassLoader extends URLClassLoader {
|
||||
if (name.equals("") && hasURLs()) {
|
||||
return getURLs()[0];
|
||||
}
|
||||
return super.findResource(name);
|
||||
Handler.setUseFastConnectionExceptions(true);
|
||||
try {
|
||||
return super.findResource(name);
|
||||
}
|
||||
finally {
|
||||
Handler.setUseFastConnectionExceptions(false);
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
return null;
|
||||
@@ -94,7 +100,13 @@ public class LaunchedURLClassLoader extends URLClassLoader {
|
||||
if (name.equals("") && hasURLs()) {
|
||||
return Collections.enumeration(Arrays.asList(getURLs()));
|
||||
}
|
||||
return super.findResources(name);
|
||||
Handler.setUseFastConnectionExceptions(true);
|
||||
try {
|
||||
return super.findResources(name);
|
||||
}
|
||||
finally {
|
||||
Handler.setUseFastConnectionExceptions(false);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasURLs() {
|
||||
@@ -291,6 +303,6 @@ public class LaunchedURLClassLoader extends URLClassLoader {
|
||||
return this.localResources.nextElement();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user