velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cbris...@apache.org
Subject svn commit: r1772379 - /velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java
Date Fri, 02 Dec 2016 17:26:34 GMT
Author: cbrisson
Date: Fri Dec  2 17:26:34 2016
New Revision: 1772379

URL: http://svn.apache.org/viewvc?rev=1772379&view=rev
Log:
[engine] be nicer with upberspectors that don't check that the base object is not null

Modified:
    velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java

Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java?rev=1772379&r1=1772378&r2=1772379&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java
(original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java
Fri Dec  2 17:26:34 2016
@@ -297,17 +297,8 @@ public class ASTReference extends Simple
                 if (result == null && !strictRef)  // If strict and null then well
catch this
                                                    // next time through the loop
                 {
-                    // do not call bad reference handler if the getter is present
-                    // (it means the getter has been called and returned null)
-                    // do not either for a quiet reference or if the *last* child failed
while testing the reference
-                    Object getter = context.icacheGet(jjtGetChild(i));
-                    if (getter == null &&
-                            referenceType != QUIET_REFERENCE  &&
-                            (!onlyTestingReference || i < jjtGetNumChildren() - 1))
-                    {
-                        failedChild = i;
-                        break;
-                    }
+                    failedChild = i;
+                    break;
                 }
             }
 
@@ -328,32 +319,42 @@ public class ASTReference extends Simple
                 }
                 else
                 {
-                    StringBuffer name = new StringBuffer("$").append(rootString);
-                    for (int i = 0; i <= failedChild; i++)
+                    Node child = jjtGetChild(failedChild);
+                    // do not call bad reference handler if the getter is present
+                    // (it means the getter has been called and returned null)
+                    // do not either for a quiet reference or if the *last* child failed
while testing the reference
+                    Object getter = context.icacheGet(child);
+                    if (getter == null &&
+                        referenceType != QUIET_REFERENCE  &&
+                        (!onlyTestingReference || failedChild < jjtGetNumChildren() -
1))
                     {
-                        Node node = jjtGetChild(i);
-                        if (node instanceof ASTMethod)
+                        StringBuffer name = new StringBuffer("$").append(rootString);
+                        for (int i = 0; i <= failedChild; i++)
+                        {
+                            Node node = jjtGetChild(i);
+                            if (node instanceof ASTMethod)
+                            {
+                                name.append(".").append(((ASTMethod) node).getMethodName()).append("()");
+                            }
+                            else
+                            {
+                                name.append(".").append(node.getFirstTokenImage());
+                            }
+                        }
+
+                        if (child instanceof ASTMethod)
                         {
-                            name.append(".").append(((ASTMethod) node).getMethodName()).append("()");
+                            String methodName = ((ASTMethod) jjtGetChild(failedChild)).getMethodName();
+                            result = EventHandlerUtil.invalidMethod(rsvc, context,
+                                name.toString(), previousResult, methodName, uberInfo);
                         }
                         else
                         {
-                            name.append(".").append(node.getFirstTokenImage());
+                            String property = jjtGetChild(failedChild).getFirstTokenImage();
+                            result = EventHandlerUtil.invalidGetMethod(rsvc, context,
+                                name.toString(), previousResult, property, uberInfo);
                         }
                     }
-                    
-                    if (jjtGetChild(failedChild) instanceof ASTMethod)
-                    {
-                        String methodName = ((ASTMethod) jjtGetChild(failedChild)).getMethodName();
-                        result = EventHandlerUtil.invalidMethod(rsvc, context,
-                                name.toString(), previousResult, methodName, uberInfo); 
                                                              
-                    }
-                    else
-                    {
-                        String property = jjtGetChild(failedChild).getFirstTokenImage();
-                        result = EventHandlerUtil.invalidGetMethod(rsvc, context, 
-                                name.toString(), previousResult, property, uberInfo);   
                    
-                    }
                 }
                 
             }



Mime
View raw message