velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nbu...@apache.org
Subject svn commit: r564330 - in /velocity/engine/trunk/src/java/org/apache/velocity/runtime: RuntimeInstance.java VelocimacroFactory.java
Date Thu, 09 Aug 2007 18:25:15 GMT
Author: nbubna
Date: Thu Aug  9 11:25:13 2007
New Revision: 564330

URL: http://svn.apache.org/viewvc?view=rev&rev=564330
Log:
passing a null logtag into evaluate() already causes macros to fail, so enforce non-null logtags
and make the error messages more helpful

Modified:
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroFactory.java

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java?view=diff&rev=564330&r1=564329&r2=564330
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java Thu Aug
 9 11:25:13 2007
@@ -1142,6 +1142,11 @@
     public boolean evaluate(Context context, Writer writer,
                             String logTag, Reader reader) throws IOException
     {
+        if (logTag == null)
+        {
+            throw new NullPointerException("logTag (i.e. template name) cannot be null, you
must provide an identifier for the content being evaluated");
+        }
+
         SimpleNode nodeTree = null;
         try
         {

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroFactory.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroFactory.java?view=diff&rev=564330&r1=564329&r2=564330
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroFactory.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroFactory.java Thu
Aug  9 11:25:13 2007
@@ -424,11 +424,31 @@
          * the caller like this...
          *
          * I hate this : maybe exceptions are in order here...
+         * They definitely would be if this was only called by directly
+         * by users, but Velocity calls this internally.
          */
-        if (name == null ||   macroBody == null || argArray == null ||
-                sourceTemplate == null)
+        if (name == null || macroBody == null || argArray == null ||
+            sourceTemplate == null)
         {
-            log.warn("VM addition rejected : programmer error : arg null");
+            String msg = "VM '"+name+"' addition rejected : ";
+            if (name == null)
+            {
+                msg += "name";
+            }
+            else if (macroBody == null)
+            {
+                msg += "macroBody";
+            }
+            else if (argArray == null)
+            {
+                msg += "argArray";
+            }
+            else
+            {
+                msg += "sourceTemplate";
+            }
+            msg += " argument was null";
+            log.warn(msg);
             return false;
         }
 



Mime
View raw message