You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by jv...@apache.org on 2001/03/15 20:28:46 UTC
cvs commit: jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node ASTIdentifier.java ASTReference.java
jvanzyl 01/03/15 11:28:46
Modified: src/java/org/apache/velocity/runtime/parser/node
ASTIdentifier.java ASTReference.java
Log:
- Fixed a bug reported by David Esposito. We now stop processing
a reference when we discover a null instead of proceeding as
we did before.
$hashtable.Customer
always worked because if Customer wasn't valid it didn't matter
because it was the last portion of the reference, but
$hashtable.Customer.Name
caused a problem because 'Customer' being null passed the null
into the next stage of processing. it's now caught and everything
is happy again :-)
Revision Changes Path
1.8 +5 -1 jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java
Index: ASTIdentifier.java
===================================================================
RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ASTIdentifier.java 2001/02/05 00:44:57 1.7
+++ ASTIdentifier.java 2001/03/15 19:28:37 1.8
@@ -71,7 +71,7 @@
*
* @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
* @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
- * @version $Id: ASTIdentifier.java,v 1.7 2001/02/05 00:44:57 geirm Exp $
+ * @version $Id: ASTIdentifier.java,v 1.8 2001/03/15 19:28:37 jvanzyl Exp $
*/
package org.apache.velocity.runtime.parser.node;
@@ -200,8 +200,12 @@
}
if (executor != null)
+ {
return executor.execute(o, context);
+ }
else
+ {
return null;
+ }
}
}
1.21 +20 -3 jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
Index: ASTReference.java
===================================================================
RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- ASTReference.java 2001/02/01 18:22:30 1.20
+++ ASTReference.java 2001/03/15 19:28:40 1.21
@@ -79,7 +79,7 @@
* @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
* @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
* @author <a href="mailto:Christoph.Reck@dlr.de">Christoph Reck</a>
- * @version $Id: ASTReference.java,v 1.20 2001/02/01 18:22:30 geirm Exp $
+ * @version $Id: ASTReference.java,v 1.21 2001/03/15 19:28:40 jvanzyl Exp $
*/
public class ASTReference extends SimpleNode
@@ -146,17 +146,34 @@
Object result = getVariableValue(context, rootString);
if (result == null)
+ {
return null;
+ }
/*
- * iteratively work 'down' (it's flat...) the reference
- * to get the value
+ * Iteratively work 'down' (it's flat...) the reference
+ * to get the value, but check to make sure that
+ * every result along the path is valid. For example:
+ *
+ * $hashtable.Customer.Name
+ *
+ * The $hashtable may be valid, but there is no key
+ * 'Customer' in the hashtable so we want to stop
+ * when we find a null value and return the null
+ * so the error gets logged.
*/
int children = jjtGetNumChildren();
for (int i = 0; i < children; i++)
+ {
result = jjtGetChild(i).execute(result,context);
+
+ if (result == null)
+ {
+ return null;
+ }
+ }
return result;
}