Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions ognl/src/main/java/ognl/OgnlRuntime.java
Original file line number Diff line number Diff line change
Expand Up @@ -668,29 +668,33 @@ public static Object invokeMethod(Object target, Method method, Object[] argsArr
}

// only synchronize method invocation if it actually requires it

synchronized (method) {
methodAccessCacheValue = _methodAccessCache.get(method);
if (methodAccessCacheValue == null) {
if (!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) {
var obj = Modifier.isStatic(method.getModifiers()) ? null : target;
if (method.canAccess(obj)) {
methodAccessCacheValue = Boolean.FALSE;
_methodAccessCache.put(method, methodAccessCacheValue);
methodAccessCacheValue = _methodAccessCache.get(method);
// double null check to avoid synchronizing on the method
if (methodAccessCacheValue == null) {
synchronized (method) {
methodAccessCacheValue = _methodAccessCache.get(method);
if (methodAccessCacheValue == null) {
if (!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) {
var obj = Modifier.isStatic(method.getModifiers()) ? null : target;
if (method.canAccess(obj)) {
methodAccessCacheValue = Boolean.FALSE;
_methodAccessCache.put(method, methodAccessCacheValue);
} else {
methodAccessCacheValue = Boolean.TRUE;
_methodAccessCache.put(method, methodAccessCacheValue);
}
} else {
methodAccessCacheValue = Boolean.TRUE;
methodAccessCacheValue = Boolean.FALSE;
_methodAccessCache.put(method, methodAccessCacheValue);
}
} else {
methodAccessCacheValue = Boolean.FALSE;
_methodAccessCache.put(method, methodAccessCacheValue);
}
}
syncInvoke = Boolean.TRUE.equals(methodAccessCacheValue);

_methodPermCache.putIfAbsent(method, Boolean.TRUE);
_methodPermCache.putIfAbsent(method, Boolean.TRUE);
}
}

syncInvoke = Boolean.TRUE.equals(methodAccessCacheValue);

Object result;

if (syncInvoke) //if is not public and is not accessible
Expand Down