Infinite recursion of the RenderTool.recurse(Context, String) method
--------------------------------------------------------------------
Key: VELTOOLS-87
URL: https://issues.apache.org/jira/browse/VELTOOLS-87
Project: Velocity Tools
Issue Type: Bug
Components: GenericTools
Affects Versions: 1.3, 1.2, 1.4, 1.x, 2.0
Reporter: Andrea Bernardo Ciddio
Priority: Critical
The recurse method never returns when the vtl template contains a loop (should
have been fixed in rev 321227):
RenderTool tool = new RenderTool();
VelocityContext ctx = new VelocityContext();
String vtl = "#set($foo = 'I am [$foo]') $foo";
System.out.println(tool.recurse(ctx, vtl));
[StackOverflow]
the issue is caused by a misplaced '++' operator in the internalRecurse method:
protected String internalRecurse(Context ctx, String vtl, int count) throws
Exception
{
String result = eval(ctx, vtl);
if (result == null || result.equals(vtl))
{
return result;
}
else
{
// if we haven't reached our parse depth...
if (count < parseDepth)
{
// continue recursing
return internalRecurse(ctx, result, count++); // <==== BUG:
should be '++count'
}
else
{
// abort and return what we have so far
//FIXME: notify the developer or user somehow??
return result;
}
}
}
The counter is updated after the recursive call returns, which never happens
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]