Moved AnnotationBeanNameGenerator's String value check right before cast
Issue: SPR-11221
This commit is contained in:
@@ -89,13 +89,16 @@ public class AnnotationBeanNameGenerator implements BeanNameGenerator {
|
||||
for (String type : types) {
|
||||
AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(amd, type);
|
||||
if (isStereotypeWithNameValue(type, amd.getMetaAnnotationTypes(type), attributes)) {
|
||||
String value = (String) attributes.get("value");
|
||||
if (StringUtils.hasLength(value)) {
|
||||
if (beanName != null && !value.equals(beanName)) {
|
||||
throw new IllegalStateException("Stereotype annotations suggest inconsistent " +
|
||||
"component names: '" + beanName + "' versus '" + value + "'");
|
||||
Object value = attributes.get("value");
|
||||
if (value instanceof String) {
|
||||
String strVal = (String) value;
|
||||
if (StringUtils.hasLength(strVal)) {
|
||||
if (beanName != null && !strVal.equals(beanName)) {
|
||||
throw new IllegalStateException("Stereotype annotations suggest inconsistent " +
|
||||
"component names: '" + beanName + "' versus '" + strVal + "'");
|
||||
}
|
||||
beanName = strVal;
|
||||
}
|
||||
beanName = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,9 +121,7 @@ public class AnnotationBeanNameGenerator implements BeanNameGenerator {
|
||||
annotationType.equals("javax.annotation.ManagedBean") ||
|
||||
annotationType.equals("javax.inject.Named");
|
||||
|
||||
return (isStereotype && attributes != null &&
|
||||
attributes.containsKey("value") &&
|
||||
attributes.get("value") instanceof String);
|
||||
return (isStereotype && attributes != null && attributes.containsKey("value"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user