Commits

Anonymous committed 0c155f0

-) Fix for OGNL-52. Added a synchronized() block around the method object being invoked to prevent failures with the accessible flag being turned on/off temporarily.

-) Added new unit test but failed to verify OGNL-51.

  • Participants
  • Parent commits bc18488

Comments (0)

Files changed (3)

File src/java/ognl/OgnlRuntime.java

         Object result;
         boolean wasAccessible = true;
 
-        if (securityManager != null) {
-            try {
-                securityManager.checkPermission(getPermission(method));
-            } catch (SecurityException ex) {
-                throw new IllegalAccessException("Method [" + method + "] cannot be accessed.");
+        synchronized(method) {
+
+            if (securityManager != null) {
+                try {
+                    securityManager.checkPermission(getPermission(method));
+                } catch (SecurityException ex) {
+                    throw new IllegalAccessException("Method [" + method + "] cannot be accessed.");
+                }
+            }
+            if (!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) {
+                if (!(wasAccessible = ((AccessibleObject) method).isAccessible())) {
+                    ((AccessibleObject) method).setAccessible(true);
+                }
+            }
+            result = method.invoke(target, argsArray);
+            if (!wasAccessible) {
+                ((AccessibleObject) method).setAccessible(false);
             }
         }
-        if (!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) {
-            if (!(wasAccessible = ((AccessibleObject) method).isAccessible())) {
-                ((AccessibleObject) method).setAccessible(true);
-            }
-        }
-        result = method.invoke(target, argsArray);
-        if (!wasAccessible) {
-            ((AccessibleObject) method).setAccessible(false);
-        }
+        
         return result;
     }
 

File src/java/ognl/enhance/ExpressionCompiler.java

 
         body = body.replaceAll("\\.\\.", ".");
 
-        //System.out.println("Getter Body: ===================================\n" + body);
+        // System.out.println("Getter Body: ===================================\n" + body);
         valueGetter.setBody(body);
 
         newClass.addMethod(valueGetter);

File src/test/java/org/ognl/test/PropertyTest.java

             { ROOT, "false", Boolean.FALSE},
             { ROOT, "!false || true", Boolean.TRUE},
             { ROOT, "testString != null && !false", Boolean.TRUE},
+            { ROOT, "!getRenderNavigation() and !getReadonly()", Boolean.TRUE},
             { ROOT, "map", ROOT.getMap() },
             { ROOT, "map.test", ROOT },
             { ROOT, "map[\"test\"]", ROOT },