mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-24 15:49:26 +00:00
Log warning if meta-annotation is ignored due to types not present
Prior to this commit, if a meta-annotation could not be loaded because its attributes referenced types not present in the classpath, the meta-annotation was silently ignored. To improve diagnostics for such use cases, this commit introduces WARN support in IntrospectionFailureLogger and revises AttributeMethods.canLoad() to log a warning if a meta-annotation is ignored due to an exception thrown while attempting to load its attributes. For example, a warning similar to the following is now logged in such cases. WARN o.s.c.a.MergedAnnotation - Failed to introspect meta-annotation @example.MyAnnotation on class example.Config: java.lang.TypeNotPresentException: Type example.OptionalDependency not present This commit also improves log messages in AnnotationTypeMappings. Closes gh-35927
This commit is contained in:
+2
-2
@@ -112,7 +112,7 @@ class AttributeMethodsTests {
|
||||
ClassValue annotation = mockAnnotation(ClassValue.class);
|
||||
given(annotation.value()).willThrow(TypeNotPresentException.class);
|
||||
AttributeMethods attributes = AttributeMethods.forAnnotationType(annotation.annotationType());
|
||||
assertThat(attributes.canLoad(annotation)).isFalse();
|
||||
assertThat(attributes.canLoad(annotation, getClass())).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -121,7 +121,7 @@ class AttributeMethodsTests {
|
||||
ClassValue annotation = mock();
|
||||
given(annotation.value()).willReturn((Class) InputStream.class);
|
||||
AttributeMethods attributes = AttributeMethods.forAnnotationType(annotation.annotationType());
|
||||
assertThat(attributes.canLoad(annotation)).isTrue();
|
||||
assertThat(attributes.canLoad(annotation, getClass())).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user