Merge branch '5.1.x'
This commit is contained in:
@@ -369,10 +369,10 @@ public class AnnotationAttributes extends LinkedHashMap<String, Object> {
|
||||
}
|
||||
|
||||
private void assertNotException(String attributeName, Object attributeValue) {
|
||||
if (attributeValue instanceof Exception) {
|
||||
if (attributeValue instanceof Throwable) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"Attribute '%s' for annotation [%s] was not resolvable due to exception [%s]",
|
||||
attributeName, this.displayName, attributeValue), (Exception) attributeValue);
|
||||
attributeName, this.displayName, attributeValue), (Throwable) attributeValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,26 +385,6 @@ public class AnnotationAttributes extends LinkedHashMap<String, Object> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the supplied {@code value} in this map under the specified
|
||||
* {@code key}, unless a value is already stored under the key.
|
||||
* @param key the key under which to store the value
|
||||
* @param value the value to store
|
||||
* @return the current value stored in this map, or {@code null} if no
|
||||
* value was previously stored in this map
|
||||
* @see #get
|
||||
* @see #put
|
||||
* @since 4.2
|
||||
*/
|
||||
@Override
|
||||
public Object putIfAbsent(String key, Object value) {
|
||||
Object obj = get(key);
|
||||
if (obj == null) {
|
||||
obj = put(key, value);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
Iterator<Map.Entry<String, Object>> entries = entrySet().iterator();
|
||||
|
||||
@@ -72,13 +72,21 @@ public class AnnotationAttributesTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unresolvableClass() throws Exception {
|
||||
public void unresolvableClassWithClassNotFoundException() throws Exception {
|
||||
attributes.put("unresolvableClass", new ClassNotFoundException("myclass"));
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
attributes.getClass("unresolvableClass"))
|
||||
.withMessageContaining("myclass");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unresolvableClassWithLinkageError() throws Exception {
|
||||
attributes.put("unresolvableClass", new LinkageError("myclass"));
|
||||
exception.expect(IllegalArgumentException.class);
|
||||
exception.expectMessage(containsString("myclass"));
|
||||
attributes.getClass("unresolvableClass");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void singleElementToSingleElementArrayConversionSupport() throws Exception {
|
||||
Filter filter = FilteredClass.class.getAnnotation(Filter.class);
|
||||
|
||||
Reference in New Issue
Block a user