You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by bu...@apache.org on 2004/10/07 18:04:01 UTC
DO NOT REPLY [Bug 31583] New: -
RenderTool throws NPE if VTL is null
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: velocity-dev@jakarta.apache.org
ReportedBy: tcolson@cisco.com
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: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org