Check for instanceof Throwable in AnnotationAttributes#assertNotException

Prior to this commit, AnnotationAttributes#assertNotException checked if
the attribute value was an instance of Exception. Although this was
typically sufficient, the scope was not always broad enough -- for
example, if AnnotationReadingVisitorUtils#convertClassValues stored a
Throwable in the map (such as a LinkageError).

This commit fixes this by checking for an instance of Throwable in
AnnotationAttributes#assertNotException.

Closes gh-23424
This commit is contained in:
Sam Brannen
2019-08-06 18:06:00 +02:00
parent 70be7117f3
commit a092dc055e
2 changed files with 11 additions and 3 deletions

View File

@@ -77,13 +77,21 @@ public class AnnotationAttributesTests {
}
@Test
public void unresolvableClass() throws Exception {
public void unresolvableClassWithClassNotFoundException() throws Exception {
attributes.put("unresolvableClass", new ClassNotFoundException("myclass"));
exception.expect(IllegalArgumentException.class);
exception.expectMessage(containsString("myclass"));
attributes.getClass("unresolvableClass");
}
@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);