cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r1128220 - /cocoon/cocoon3/trunk/cocoon-stringtemplate/src/main/java/org/apache/cocoon/stringtemplate/StringTemplateGenerator.java
Date Fri, 27 May 2011 09:50:54 GMT
Author: reinhard
Date: Fri May 27 09:50:54 2011
New Revision: 1128220

URL: http://svn.apache.org/viewvc?rev=1128220&view=rev
Log:
prevent potential NPE in the addTemplateAttributes(...) method

Modified:
    cocoon/cocoon3/trunk/cocoon-stringtemplate/src/main/java/org/apache/cocoon/stringtemplate/StringTemplateGenerator.java

Modified: cocoon/cocoon3/trunk/cocoon-stringtemplate/src/main/java/org/apache/cocoon/stringtemplate/StringTemplateGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-stringtemplate/src/main/java/org/apache/cocoon/stringtemplate/StringTemplateGenerator.java?rev=1128220&r1=1128219&r2=1128220&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-stringtemplate/src/main/java/org/apache/cocoon/stringtemplate/StringTemplateGenerator.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-stringtemplate/src/main/java/org/apache/cocoon/stringtemplate/StringTemplateGenerator.java
Fri May 27 09:50:54 2011
@@ -101,7 +101,7 @@ public class StringTemplateGenerator ext
                     }
 
                     public String toString(Object o, String string) {
-                        return toString(o);
+                        return this.toString(o);
                     }
                 });
 
@@ -119,6 +119,15 @@ public class StringTemplateGenerator ext
         }
     }
 
+    public void setSource(URL source) {
+        this.source = source;
+    }
+
+    @Override
+    public void setup(Map<String, Object> parameters) {
+        this.parameters = parameters;
+    }
+
     /**
      * Add attributes to the StringTemplate. Be careful to keep the constructCacheKey() method
      * align.
@@ -126,6 +135,11 @@ public class StringTemplateGenerator ext
      * @param stringTemplate The template where the attributes are added to.
      */
     protected void addTemplateAttributes(StringTemplate stringTemplate) {
+        if(this.parameters == null) {
+            this.logger.warn("There are not any parameters passed to the template.");
+            return;
+        }
+
         for (Entry<String, Object> eachEntry : this.parameters.entrySet()) {
             stringTemplate.setAttribute(eachEntry.getKey().replace(".", "_"), eachEntry.getValue());
 
@@ -135,14 +149,4 @@ public class StringTemplateGenerator ext
             }
         }
     }
-
-
-    @Override
-    public void setup(Map<String, Object> parameters) {
-        this.parameters = parameters;
-    }
-
-    public void setSource(URL source) {
-        this.source = source;
-    }
 }



Mime
View raw message