SimpleAliasRegistry detects resolved aliases that loop back to the original name (SPR-5419); PropertyPlaceholderConfigurer does not modify Map in case of equal String keys (SPR-5318); inner class names in Java source style ("java.lang.Thread.State") supported as well (SPR-5210)
This commit is contained in:
@@ -117,7 +117,10 @@ public class SimpleAliasRegistry implements AliasRegistry {
|
||||
String registeredName = aliasCopy.get(alias);
|
||||
String resolvedAlias = valueResolver.resolveStringValue(alias);
|
||||
String resolvedName = valueResolver.resolveStringValue(registeredName);
|
||||
if (!resolvedAlias.equals(alias)) {
|
||||
if (resolvedAlias.equals(resolvedName)) {
|
||||
this.aliasMap.remove(alias);
|
||||
}
|
||||
else if (!resolvedAlias.equals(alias)) {
|
||||
String existingName = this.aliasMap.get(resolvedAlias);
|
||||
if (existingName != null && !existingName.equals(resolvedName)) {
|
||||
throw new IllegalStateException(
|
||||
@@ -125,8 +128,8 @@ public class SimpleAliasRegistry implements AliasRegistry {
|
||||
"') for name '" + resolvedName + "': It is already registered for name '" +
|
||||
registeredName + "'.");
|
||||
}
|
||||
this.aliasMap.put(resolvedAlias, resolvedName);
|
||||
this.aliasMap.remove(alias);
|
||||
this.aliasMap.put(resolvedAlias, resolvedName);
|
||||
}
|
||||
else if (!registeredName.equals(resolvedName)) {
|
||||
this.aliasMap.put(alias, resolvedName);
|
||||
|
||||
@@ -201,7 +201,9 @@ public abstract class ClassUtils {
|
||||
|
||||
/**
|
||||
* Replacement for <code>Class.forName()</code> that also returns Class instances
|
||||
* for primitives (like "int") and array class names (like "String[]").
|
||||
* for primitives (e.g."int") and array class names (e.g. "String[]").
|
||||
* Furthermore, it is also capable of resolving inner class names in Java source
|
||||
* style (e.g. "java.lang.Thread.State" instead of "java.lang.Thread$State").
|
||||
* @param name the name of the Class
|
||||
* @param classLoader the class loader to use
|
||||
* (may be <code>null</code>, which indicates the default class loader)
|
||||
@@ -246,7 +248,22 @@ public abstract class ClassUtils {
|
||||
if (classLoaderToUse == null) {
|
||||
classLoaderToUse = getDefaultClassLoader();
|
||||
}
|
||||
return classLoaderToUse.loadClass(name);
|
||||
try {
|
||||
return classLoaderToUse.loadClass(name);
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
int lastDotIndex = name.lastIndexOf('.');
|
||||
if (lastDotIndex != -1) {
|
||||
String innerClassName = name.substring(0, lastDotIndex) + '$' + name.substring(lastDotIndex + 1);
|
||||
try {
|
||||
return classLoaderToUse.loadClass(innerClassName);
|
||||
}
|
||||
catch (ClassNotFoundException ex2) {
|
||||
// swallow - let original exception get through
|
||||
}
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user