Author: nbubna
Date: Sun Mar 28 21:36:36 2010
New Revision: 928499

URL: http://svn.apache.org/viewvc?rev=928499&view=rev
Log:
VELOCITY-759 prevent NPEs when deprecated props are misconfigured :) (thanks to 
Rachid)

Modified:
    velocity/engine/trunk/src/changes/changes.xml
    
velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java

Modified: velocity/engine/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/src/changes/changes.xml?rev=928499&r1=928498&r2=928499&view=diff
==============================================================================
--- velocity/engine/trunk/src/changes/changes.xml (original)
+++ velocity/engine/trunk/src/changes/changes.xml Sun Mar 28 21:36:36 2010
@@ -26,6 +26,10 @@
 
   <body>
     <release version="1.7" date="In Subversion">
+      <action type="add" dev="nbubna" issue="VELOCITY-759" due-to="Rachid">
+    Avoid NPEs in case of bad #foreach config.
+      </action>
+
       <action type="add" dev="nbubna" issue="VELOCITY-755">
     Use LinkedHashMap to maintain order of VTL-created maps.
       </action>

Modified: 
velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java?rev=928499&r1=928498&r2=928499&view=diff
==============================================================================
--- 
velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java
 (original)
+++ 
velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java
 Sun Mar 28 21:36:36 2010
@@ -214,7 +214,7 @@ public class Foreach extends Directive
         {
             warned = true;
             // ...and only if they customize these settings
-            if (!counterName.equals("velocityCount"))
+            if (!"velocityCount".equals(counterName))
             {
                 rsvc.getLog().warn("The "+RuntimeConstants.COUNTER_NAME+
                     " property has been deprecated. It will be removed"+
@@ -222,7 +222,7 @@ public class Foreach extends Directive
                     " Instead, please use $foreach.count to access"+
                     " the loop counter.");
             }
-            if (!hasNextName.equals("velocityHasNext"))
+            if (!"velocityHasNext".equals(hasNextName))
             {
                 rsvc.getLog().warn("The "+RuntimeConstants.HAS_NEXT_NAME+
                     " property has been deprecated. It will be removed"+


Reply via email to