Uploaded image for project: 'Shiro'
  1. Shiro
  2. SHIRO-473

DefaultAnnotationResolver.getAnnotation throws NullPointerException

    XMLWordPrintableJSON

Details

    Description

      Bug Description

      The method org.apache.shiro.aop.DefaultAnnotationResolver.getAnnotation throws NullPointerException when a given MethodInvocation argument represents static method:

      Technical Info

      http://shiro.apache.org/static/1.2.2/apidocs/src-html/org/apache/shiro/aop/DefaultAnnotationResolver.html#line.62:

      return annotation == null ? mi.getThis().getClass().getAnnotation(clazz) : annotation;
      

      if annotation is null and mi represents static method invocation, then mi.getThis() will return null causing the following chained call getClass() fail with NullPointerException.

      Resolution

      See attached patch: DefaultAnnotationResolver.java.diff.

      Attachments

        1. DefaultAnnotationResolver.java.diff
          0.7 kB
          Sergiy Sokolenko

        Activity

          People

            Unassigned Unassigned
            s.sokolenko Sergiy Sokolenko
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: