Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-9233

Reduce log level for message re: missing annotation

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 3.1.1
    • Fix Version/s: 3.2 M1
    • Component/s: Core
    • Labels:
    • Last commented by a User:
      true

      Description

      Since 3.1.1 the AbstractRecursiveAnnotationVisitor logs a warning when annotation class could not be loaded (see AbstractRecursiveAnnotationVisitor#logNonFatalException). Until 3.1.0 any Exception was catched without any message. I agree to log this but IMO this should be a debug log message. Annotations (even if RetentionPolicy.RUNTIME) may or may not be available at run-time. See also Java Language Specification:

      9.6.1.2 Retention

      Annotations may be present only in the source code, or they may be present in the binary form of a class or interface. 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.
      ...

      So there is nothing wrong about getting a ClassNotFoundException regarding annotations.

      I suggest to change the log level to debug or (IMO better) to catch ClassNotFoundException -> logger.debug(...) because it's legitimate and any other Exception -> logger.warn(...).

      Background: We currently use jsr305 with @javax.annotation.Nonnull and @javax.annotation.Nullable doing some code analyses during builds. At run-time these annotations are no longer available/needed and we get tons of warnings "Failed to classload type while reading annotation metadata. This is a non-fatal error, but certain annotation metadata may be unavailable.". Of course, it's not a problem to workaround this: we can include jsr305 or change log level in config of this logger but IMO I should not get a warning when everything is like expected and JLS-compliant.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                cbeams Chris Beams
                Reporter:
                manthos Minas Manthos
                Last updater:
                Trevor Marshall
              • Votes:
                6 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  6 years, 3 days ago

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - Not Specified
                  Not Specified
                  Logged:
                  Time Spent - 40m
                  40m