[ http://issues.apache.org/jira/browse/VELTOOLS-27?page=all ]

Tim Colson moved VELOCITY-298 to VELTOOLS-27:
---------------------------------------------

      Project: VelocityTools  (was: Velocity)
          Key: VELTOOLS-27  (was: VELOCITY-298)
    Component:     (was: Tools)
      Version:     (was: 1.2)

> RenderTool throws NPE if VTL is null
> ------------------------------------
>
>          Key: VELTOOLS-27
>          URL: http://issues.apache.org/jira/browse/VELTOOLS-27
>      Project: VelocityTools
>         Type: Bug
>  Environment: Operating System: other
> Platform: Other
>     Reporter: Tim Colson
>     Priority: Minor

>
> 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))
>           {

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


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

Reply via email to