Browse Source

Polishing

pull/1408/head
Sam Brannen 9 years ago
parent
commit
c855182e03
  1. 12
      spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java
  2. 11
      spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java

12
spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java

@ -1282,7 +1282,9 @@ public abstract class AnnotationUtils { @@ -1282,7 +1282,9 @@ public abstract class AnnotationUtils {
* Retrieve the <em>value</em> of the {@code value} attribute of a
* single-element Annotation, given an annotation instance.
* @param annotation the annotation instance from which to retrieve the value
* @return the attribute value, or {@code null} if not found
* @return the attribute value, or {@code null} if not found unless the attribute
* value cannot be retrieved due to an {@link AnnotationConfigurationException}, in
* which case such an exception will be rethrown
* @see #getValue(Annotation, String)
*/
public static Object getValue(Annotation annotation) {
@ -1293,9 +1295,9 @@ public abstract class AnnotationUtils { @@ -1293,9 +1295,9 @@ public abstract class AnnotationUtils {
* Retrieve the <em>value</em> of a named attribute, given an annotation instance.
* @param annotation the annotation instance from which to retrieve the value
* @param attributeName the name of the attribute value to retrieve
* @return the attribute value, or {@code null} if not found unless the the attribute value
* can not be retrieved due to {@link AnnotationConfigurationException}, in which case it
* will be re-thrown
* @return the attribute value, or {@code null} if not found unless the attribute
* value cannot be retrieved due to an {@link AnnotationConfigurationException}, in
* which case such an exception will be rethrown
* @see #getValue(Annotation)
* @see #rethrowAnnotationConfigurationException(Throwable)
*/
@ -1311,7 +1313,7 @@ public abstract class AnnotationUtils { @@ -1311,7 +1313,7 @@ public abstract class AnnotationUtils {
catch (InvocationTargetException ex) {
rethrowAnnotationConfigurationException(ex.getTargetException());
throw new IllegalStateException(
"Could not obtain value for annotation attribute '" + attributeName + "' on " + annotation, ex);
"Could not obtain value for annotation attribute '" + attributeName + "' in " + annotation, ex);
}
catch (Throwable ex) {
return null;

11
spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java

@ -1240,10 +1240,13 @@ public class AnnotationUtilsTests { @@ -1240,10 +1240,13 @@ public class AnnotationUtilsTests {
assertEquals("value: ", "", contextConfig.value());
assertEquals("location: ", "", contextConfig.location());
}
@Test(expected = AnnotationConfigurationException.class)
public void synthesizeAnnotationWithAttributeAliasesDifferentValues() throws Exception {
getValue(synthesizeAnnotation(ContextConfigMismatch.class.getAnnotation(ContextConfig.class)));
@Test
public void synthesizeAnnotationWithAttributeAliasesWithDifferentValues() throws Exception {
ContextConfig contextConfig = synthesizeAnnotation(ContextConfigMismatch.class.getAnnotation(ContextConfig.class));
exception.expect(AnnotationConfigurationException.class);
getValue(contextConfig);
}
@Test

Loading…
Cancel
Save