Fix issue with Spring Boot now using Spring component in CGLIB names - github issue #49

This commit is contained in:
Andy Clement
2014-03-11 15:39:22 -07:00
parent 513257a84d
commit 93f9ab4444
4 changed files with 11 additions and 7 deletions

View File

@@ -109,7 +109,10 @@ public class SystemPropertyConfiguredIsReloadableTypePlugin implements IsReloada
// May have to do something special for CGLIB types
// These will have a type name of something like: grails/plugin/springsecurity/SpringSecurityService$$EnhancerByCGLIB$$8f956be2
// But a codesource location of file:/Users/aclement/.m2/repository/org/springframework/spring-core/3.2.5.RELEASE/spring-core-3.2.5.RELEASE.jar
int cglibIndex = typename.indexOf("ByCGLIB$$"); // catches fastclass too
int cglibIndex = typename.indexOf("$$EnhancerBy");
if (cglibIndex == -1) {
cglibIndex = typename.indexOf("$$FastClassBy");
}
if (cglibIndex != -1) {
String originalType = typename.substring(0, typename.indexOf("$$")); // assuming first $$ is good enough
while (typeRegistry != null) {

View File

@@ -599,8 +599,8 @@ public class TypeRegistry {
}
}
}
if (slashedName.startsWith("$Proxy") || slashedName.indexOf("EnhancerByCGLIB") != -1
|| slashedName.indexOf("FastClassByCGLIB") != -1) {
if (slashedName.startsWith("$Proxy") || slashedName.indexOf("$$EnhancerBy") != -1
|| slashedName.indexOf("$$FastClassBy") != -1) {
return true;
}
// TODO review all these... are these four only loaded by jasperloader?
@@ -940,8 +940,8 @@ public class TypeRegistry {
}
// allocatedIds.put(slashname, rtype);
// allocatedButNotYetRegisteredItds.remove(slashname);
int cglibIndex = slashname.indexOf("$$EnhancerByCGLIB");
int fcIndex = slashname.indexOf("$$FastClassByCGLIB"); // a type can have both (the fast class for a proxy)
int cglibIndex = slashname.indexOf("$$EnhancerBy");
int fcIndex = slashname.indexOf("$$FastClassBy"); // a type can have both (the fast class for a proxy)
if (fcIndex != -1) {
String originalType = slashname.substring(0, fcIndex);
cglibProxiesFastClass.put(originalType, rtype);

View File

@@ -63,6 +63,7 @@ public class JVMPlugin implements ReloadEventProcessorPlugin, LoadtimeInstrument
ConcurrentMap cm = (ConcurrentMap)localDescsField.get(null);
// TODO [serialization] a bit extreme to wipe out everything
cm.clear();
// For some reason clearing the reflectors damages serialization - is it not a true cache?
// Field reflectorsField = clazz.getDeclaredField("reflectors");
// reflectorsField.setAccessible(true);
// cm = (ConcurrentMap)reflectorsField.get(null);

View File

@@ -134,7 +134,7 @@ public class SpringLoadedPreProcessor implements Constants {
}
if (typeRegistry == null) { // A null type registry indicates nothing is being made reloadable for the classloader
if (classLoader == null) { // Indicates loading of a system class
if (classLoader == null && slashedClassName != null) { // Indicates loading of a system class
if (systemClassesContainingReflection.contains(slashedClassName)) {
try {
// TODO [perf] why are we not using the cache here, is it because the list is so short?
@@ -204,7 +204,7 @@ public class SpringLoadedPreProcessor implements Constants {
// codesource determined to be: file:/Users/aclement/springsource/tc-server-developer-2.1.1.RELEASE/spring-insight-instance/wtpwebapps/hello-rabbit-client/WEB-INF/lib/cglib-nodep-2.2.jar <no signer certificates>
// But if the type 'com/vmware/rabbit/ApplicationContext' is reloadable, then this should be too
boolean makeReloadableAnyway = false;
int cglibIndex = slashedClassName.indexOf("$$EnhancerByCGLIB");
int cglibIndex = slashedClassName.indexOf("$$EnhancerBy");
if (cglibIndex != -1) {
String originalType = slashedClassName.substring(0, cglibIndex);