Skip to content

Improve diagnostics when OrderUtils.getPriority encounters an ArrayStoreException during annotation introspection [SPR-12357] #16962

Closed

Description

@spring-projects-issues

Andy Wilkinson opened SPR-12357 and commented

I noticed this while testing the fix for #16930. I was running an app on Tomcat 8 (where javax.annotation.Priority is available).

OrderUtils.getPriority calls Class.getAnnotations() directly so it doesn't benefit from the recent improvements to AnnotationUtils' diagnostics. Could OrderUtils.getPriority be updated to use AnnotationUtils in a similar fashion to OrderUtils.getOrder?


Affects: 4.1.1

Issue Links:

Referenced from: commits 2b6f841

Activity

  1. spring-projects-issues commented on Oct 21, 2014

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    We're detecting @Priority through the regular AnnotationUtils.findAnnotation method now. This has the side benefit of it being detected on a composed annotation as well (even if that's not the intended usage model of that standard annotation, it doesn't hurt for it to work along the lines of our own @Order).

    Juergen

  2. spring-projects-issues commented on Dec 1, 2014

    @spring-projects-issues
    CollaboratorAuthor

    zyro commented

    hi, could it be that this change caused a regression in terms of broken jdk 6 compatibility?

    i am seeing

    java.lang.UnsupportedClassVersionError: javax/annotation/Priority : Unsupported major.minor version 51.0
    ...
    at org.springframework.util.ClassUtils.forName(ClassUtils.java:249)
    at org.springframework.core.annotation.OrderUtils.<clinit>(OrderUtils.java:41)
    ...
    

    and the code looks like only a ClassNotFoundException is expected/caught, but not that java.lang.UnsupportedClassVersionError?

    was testing locally with oracle jdk 1.6.0_45 x64

    thanks, zyro

  3. spring-projects-issues commented on Dec 1, 2014

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    Hmm, this means that you do have the javax.annotation.Priority class on your classpath though... Is this intentional? From a Spring perspective, this is an optional dependency which should only ever be present on JDK 7+ to begin with...

    That said, we should be more defensive there and catch any kind of error. Could you please create a separate JIRA issue for it?

    Juergen

  4. spring-projects-issues commented on Dec 1, 2014

    @spring-projects-issues
    CollaboratorAuthor

    zyro commented

    hi i just saw that the offending javax.annotation.Priority class ships with tomcat-embed-core-8.x which clearly states that it requires jdk7+. no good idea to try run a jdk6 app on it anyway ;) - ill file the separate jira but for my part, consider it as low prio.

  5. spring-projects-issues commented on Dec 1, 2014

    @spring-projects-issues
    CollaboratorAuthor

    zyro commented

    here you go: #17095 thanks, zyro

  6. added
    type: enhancement
    in: core
    on Jan 11, 2019
  7. added this to the 4.1.2 milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coretype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions