Author: fmeschbe
Date: Mon Jan 19 10:23:37 2015
New Revision: 1652954
URL: http://svn.apache.org/r1652954
Log:
SLING-4314 The implementation of RenderContext#resolveProperty can be slow for
certain cases
My change to the patch caused NPE. So a another refactoring is
needed for the findMethod method: Only return if the matched method
is accepatble. Otherwise break out of the loop and fall down to
throwing the NoSuchMethodException thus never returning
null from findMethod.
Modified:
sling/trunk/contrib/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/engine/runtime/RenderContextImpl.java
Modified:
sling/trunk/contrib/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/engine/runtime/RenderContextImpl.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/engine/runtime/RenderContextImpl.java?rev=1652954&r1=1652953&r2=1652954&view=diff
==============================================================================
---
sling/trunk/contrib/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/engine/runtime/RenderContextImpl.java
(original)
+++
sling/trunk/contrib/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/engine/runtime/RenderContextImpl.java
Mon Jan 19 10:23:37 2015
@@ -347,14 +347,17 @@ public class RenderContextImpl implement
for (Method m : publicMethods) {
if (m.getParameterTypes().length == 0) {
String methodName = m.getName();
- if (baseName.equals(methodName)) {
- return (isMethodAllowed(m)) ? m : null;
- }
- if (("get" + capitalized).equals(methodName)) {
- return (isMethodAllowed(m)) ? m : null;
- }
- if (("is" + capitalized).equals(methodName)) {
- return (isMethodAllowed(m)) ? m : null;
+ if (baseName.equals(methodName)
+ || ("get" + capitalized).equals(methodName)
+ || ("is" + capitalized).equals(methodName)) {
+
+ // this method is good, check whether allowed
+ if (isMethodAllowed(m)) {
+ return m;
+ }
+
+ // method would match but is not allwed, abort
+ break;
}
}
}