DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31583>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31583

RenderTool throws NPE if VTL is null

           Summary: RenderTool throws NPE if VTL is null
           Product: Velocity
           Version: 1.1
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Tools
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Just found that passing a reference into the ViewRenderTool which is null or
bogus causes RenderTool to throw an NPE.

I took a simple-minded approach to avoid this by checking for null and returning
"" -- I'm okay with $render.eval($!NOTEXISTS) yielding "". 

Not sure what happens in the case of $render.eval($NOTEXISTS).

C:\java\jakarta-velocity-tools\src\java\org\apache\velocity\tools\generic>cvs di
ff -p RenderTool.java
Index: RenderTool.java
===================================================================
RCS file: /home/cvspublic/jakarta-velocity-tools/src/java/org/apache/velocity/to
ols/generic/RenderTool.java,v
retrieving revision 1.7
diff -p -r1.7 RenderTool.java
*** RenderTool.java     9 Jun 2004 01:30:58 -0000       1.7
--- RenderTool.java     7 Oct 2004 15:52:29 -0000
*************** public class RenderTool
*** 95,100 ****
--- 95,101 ----
       */
      public String eval(Context ctx, String vtl) throws Exception
      {
+         if (null == vtl) { return ""; }
          StringWriter sw = new StringWriter();
          boolean success = Velocity.evaluate(ctx, sw, LOG_TAG, vtl);
          if (success)
*************** public class RenderTool
*** 120,125 ****
--- 121,127 ----
       */
      public String recurse(Context ctx, String vtl) throws Exception
      {
+         if (null == vtl) { return ""; }
          String result = eval(ctx, vtl);
          if (result == null || result.equals(vtl))
          {

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to