orphan-oss / ognl

Object Graph Navigation Library

Home Page:https://orphan.software

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add short circuit for public method to avoid unnecessary synchronization and cache

quaff opened this issue · comments

Here is my proposal:
add

         if (Modifier.isPublic(method.getModifiers()) && Modifier.isPublic(method.getDeclaringClass().getModifiers()))
         {
     			// real public method should invoke directly
     			return method.invoke(target, argsArray);
         }

before
https://github.com/jkuhnert/ognl/blob/32d076d209c11da12bebe48d88321b961ac1b087/src/java/ognl/OgnlRuntime.java#L1132

@yasserzamani @lukaszlenart WDYT?

It at least misses two things: checkPermission and invokeMethodInSandbox.

Please think twice, is it necessary for real public methods? if yes, we could call it before real method invoke, my point is avoiding synchronization and reduce cache size.

I've tested one simple scene of my actual application, throughput could increase about 5%, I think it worth a shot.

Hello.

The proposed change might improve performance (avoiding some synchronization) for public method calls but there may not be a clean way to preserve the permission checks and sandboxing calls in the new code path (without reintroducing some form of synchronization). Some kind of opt-in mechanism to bypass the checks/synchronization for public methods might be possible ... but the risk of bypassing the checks probably outweighs a small performance gain.