mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-15 01:07:30 +08:00
Protect against multiple define package calls
Ensure that multiple calls to define package are not made when the same class is contained in multiple jars.
This commit is contained in:
parent
dc1b787a01
commit
8d39abb8d9
@ -46,7 +46,12 @@ public class LaunchedURLClassLoader extends URLClassLoader {
|
|||||||
if (lastDot != -1) {
|
if (lastDot != -1) {
|
||||||
String packageName = name.substring(0, lastDot);
|
String packageName = name.substring(0, lastDot);
|
||||||
if (getPackage(packageName) == null) {
|
if (getPackage(packageName) == null) {
|
||||||
definePackageForFindClass(name, packageName);
|
try {
|
||||||
|
definePackageForFindClass(name, packageName);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
// Swallow and continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.findClass(name);
|
return super.findClass(name);
|
||||||
@ -72,6 +77,7 @@ public class LaunchedURLClassLoader extends URLClassLoader {
|
|||||||
if (jarFile.getManifest() != null
|
if (jarFile.getManifest() != null
|
||||||
&& jarFile.getJarEntry(path) != null) {
|
&& jarFile.getJarEntry(path) != null) {
|
||||||
definePackage(packageName, jarFile.getManifest(), url);
|
definePackage(packageName, jarFile.getManifest(), url);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user