From f55a4a1ac5a202f00dc427ba0f94d5123ec7b2de Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Sun, 27 May 2012 13:27:39 +0300 Subject: [PATCH] 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 --- .../AnnotationAttributesReadingVisitor.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationAttributesReadingVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationAttributesReadingVisitor.java index 7f48ece4fd..c71d06bf06 100644 --- a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationAttributesReadingVisitor.java +++ b/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationAttributesReadingVisitor.java @@ -80,18 +80,14 @@ abstract class AbstractRecursiveAnnotationVisitor implements AnnotationVisitor { valueToUse = enumConstant.get(null); } } - catch (Exception ex) { - logNonFatalException(ex); + catch (ClassNotFoundException ex) { + this.logger.debug("Failed to classload enum type while reading annotation metadata", ex); + } + catch (IllegalAccessException ex) { + this.logger.warn("Could not access enum value while reading annotation metadata", ex); } this.attributes.put(attributeName, valueToUse); } - - - protected void logNonFatalException(Exception ex) { - this.logger.warn("Failed to classload type while reading annotation metadata. " + - "This is a non-fatal error, but certain annotation metadata may be " + - "unavailable.", ex); - } } @@ -168,7 +164,9 @@ class RecursiveAnnotationAttributesVisitor extends AbstractRecursiveAnnotationVi this.doVisitEnd(annotationClass); } catch (ClassNotFoundException ex) { - logNonFatalException(ex); + this.logger.debug("Failed to classload type while reading annotation " + + "metadata. This is a non-fatal error, but certain annotation " + + "metadata may be unavailable.", ex); } }