diff --git a/pom.xml b/pom.xml
index 9f207e38..2b345d07 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
ognl
ognl
jar
- 3.1.14
+ 3.1.15-SNAPSHOT
OGNL - Object Graph Navigation Library
OGNL - Object Graph Navigation Library
diff --git a/src/java/ognl/OgnlRuntime.java b/src/java/ognl/OgnlRuntime.java
index ed8217f1..3424d7cf 100644
--- a/src/java/ognl/OgnlRuntime.java
+++ b/src/java/ognl/OgnlRuntime.java
@@ -825,21 +825,48 @@ public static Object invokeMethod(Object target, Method method, Object[] argsArr
// only synchronize method invocation if it actually requires it
synchronized(method) {
- if (_methodAccessCache.get(method) == null
- || _methodAccessCache.get(method) == Boolean.TRUE) {
+ if (_methodAccessCache.get(method) == null) {
+ if (!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers()))
+ {
+ if (!(((AccessibleObject) method).isAccessible()))
+ {
+ _methodAccessCache.put(method, Boolean.TRUE);
+ } else
+ {
+ _methodAccessCache.put(method, Boolean.FALSE);
+ }
+ } else
+ {
+ _methodAccessCache.put(method, Boolean.FALSE);
+ }
+ }
+ if (_methodAccessCache.get(method) == Boolean.TRUE) {
syncInvoke = true;
}
- if (_securityManager != null && _methodPermCache.get(method) == null
- || _methodPermCache.get(method) == Boolean.FALSE) {
+ if (_methodPermCache.get(method) == null) {
+ if (_securityManager != null) {
+ try
+ {
+ _securityManager.checkPermission(getPermission(method));
+ _methodPermCache.put(method, Boolean.TRUE);
+ } catch (SecurityException ex) {
+ _methodPermCache.put(method, Boolean.FALSE);
+ throw new IllegalAccessException("Method [" + method + "] cannot be accessed.");
+ }
+ }
+ else {
+ _methodPermCache.put(method, Boolean.TRUE);
+ }
+ }
+ if (_methodPermCache.get(method) == Boolean.FALSE) {
checkPermission = true;
}
}
Object result;
- boolean wasAccessible = true;
- if (syncInvoke)
+ if (syncInvoke) //if is not public and is not accessible
{
synchronized(method)
{
@@ -848,34 +875,14 @@ public static Object invokeMethod(Object target, Method method, Object[] argsArr
try
{
_securityManager.checkPermission(getPermission(method));
- _methodPermCache.put(method, Boolean.TRUE);
} catch (SecurityException ex) {
- _methodPermCache.put(method, Boolean.FALSE);
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);
- _methodAccessCache.put(method, Boolean.TRUE);
- } else
- {
- _methodAccessCache.put(method, Boolean.FALSE);
- }
- } else
- {
- _methodAccessCache.put(method, Boolean.FALSE);
- }
-
+ ((AccessibleObject) method).setAccessible(true);
result = method.invoke(target, argsArray);
-
- if (!wasAccessible)
- {
- ((AccessibleObject) method).setAccessible(false);
- }
+ ((AccessibleObject) method).setAccessible(false);
}
} else
{
@@ -884,9 +891,7 @@ public static Object invokeMethod(Object target, Method method, Object[] argsArr
try
{
_securityManager.checkPermission(getPermission(method));
- _methodPermCache.put(method, Boolean.TRUE);
} catch (SecurityException ex) {
- _methodPermCache.put(method, Boolean.FALSE);
throw new IllegalAccessException("Method [" + method + "] cannot be accessed.");
}
}