Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-5006

NullPointerException in ProxyUtil class when accessing static member

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.5.20
    • Fix Version/s: 2.5.22, 2.6
    • Component/s: Value Stack
    • Labels:
      None

      Description

      In some JSP we access static fields (constants) of an interface. The interface has scope public and and the fields are public static final.

      When accessing the value of such a field the ValueStack throws a NullPointerException here (com.opensymphony.xwork2.util.ProxyUtil), because there is actually no object (parameter holds null) when accessing a static member:

      /**
      * Check whether the given object is a proxy.
      * @param object the object to check
      */
      public static boolean isProxy(Object object) {
      Class<?> clazz = object.getClass();
      Boolean flag = isProxyCache.get(clazz);
      if (flag != null) {
      return flag;
      }
      
      boolean isProxy = isSpringAopProxy(object);
      
      isProxyCache.put(clazz, isProxy);
      return isProxy;
      }
      
      

       

      Support to access static members is switched on via struts constant 

      <constant name="struts.ognl.allowStaticMethodAccess" value="true" />

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                s.goetz Sebastian Götz
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: