Skip to content

Commit f55a4a1

Browse files
committed
Reduce log level for message re: missing annotation
Previously (since Spring 3.1.1) RecursiveAnnotationAttributesVisitor logs at level WARN when ASM parsing encounters an annotation or an (enum used within an annotation) that cannot be classloaded. This is not necessarily indicative of an error, e.g. JSR-305 annotations such as @nonnull may be used only for static analysis purposes, but because these annotations have runtime retention, they remain present in the bytecode. Per section 9.6.1.2 of the JLS, "An annotation that is present in the binary may or may not be available at run-time via the reflective libraries of the Java platform." This commit lowers the log level of these messages from warn to debug, but leaves at warn level other messages dealing with the ability reflectively read enum values from within annotations. Issue: SPR-9233
1 parent bcd44f3 commit f55a4a1

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationAttributesReadingVisitor.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,14 @@ public void visitEnum(String attributeName, String asmTypeDescriptor, String att
8080
valueToUse = enumConstant.get(null);
8181
}
8282
}
83-
catch (Exception ex) {
84-
logNonFatalException(ex);
83+
catch (ClassNotFoundException ex) {
84+
this.logger.debug("Failed to classload enum type while reading annotation metadata", ex);
85+
}
86+
catch (IllegalAccessException ex) {
87+
this.logger.warn("Could not access enum value while reading annotation metadata", ex);
8588
}
8689
this.attributes.put(attributeName, valueToUse);
8790
}
88-
89-
90-
protected void logNonFatalException(Exception ex) {
91-
this.logger.warn("Failed to classload type while reading annotation metadata. " +
92-
"This is a non-fatal error, but certain annotation metadata may be " +
93-
"unavailable.", ex);
94-
}
9591
}
9692

9793

@@ -168,7 +164,9 @@ public final void visitEnd() {
168164
this.doVisitEnd(annotationClass);
169165
}
170166
catch (ClassNotFoundException ex) {
171-
logNonFatalException(ex);
167+
this.logger.debug("Failed to classload type while reading annotation " +
168+
"metadata. This is a non-fatal error, but certain annotation " +
169+
"metadata may be unavailable.", ex);
172170
}
173171
}
174172

0 commit comments

Comments
 (0)