Author: byron
Date: Wed Feb 11 06:34:36 2009
New Revision: 743247

URL: http://svn.apache.org/viewvc?rev=743247&view=rev
Log:
In strict mode, throw an exception if the argument to #parse is null

Modified:
    
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Parse.java

Modified: 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Parse.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Parse.java?rev=743247&r1=743246&r2=743247&view=diff
==============================================================================
--- 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Parse.java
 (original)
+++ 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Parse.java
 Wed Feb 11 06:34:36 2009
@@ -72,6 +72,11 @@
     boolean localscope = false;    
     
     /**
+     * Indicates if we are running in strict reference mode.
+     */
+    public boolean strictRef = false;    
+    
+    /**
      * Return name of this directive.
      * @return The name of this directive.
      */
@@ -104,7 +109,9 @@
         this.maxDepth = rsvc.getInt(RuntimeConstants.PARSE_DIRECTIVE_MAXDEPTH, 
10);
 
         // support for local context scope feature, where all references are 
local
-        localscope = rsvc.getBoolean(RuntimeConstants.VM_CONTEXT_LOCALSCOPE, 
false);        
+        localscope = rsvc.getBoolean(RuntimeConstants.VM_CONTEXT_LOCALSCOPE, 
false);  
+        
+        strictRef = 
rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT, false);        
     }
 
     /**
@@ -141,6 +148,12 @@
 
         if ( value == null)
         {
+            if (strictRef)
+            {
+                throw new VelocityException("The argument to #parse returned 
null at "
+                  + Log.formatFileString(this));
+            }
+            
             rsvc.getLog().error("#parse() null argument");
             return  false;
         }


Reply via email to