velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kishore Senji <kse...@gmail.com>
Subject Re: Bug in nested #parse()
Date Thu, 12 Aug 2004 21:01:46 GMT
On Thu, 12 Aug 2004 10:41:32 -0500, Ford, Peter
<peter.ford@travelocity.com> wrote:
> There seems to be a problem in Velocity in which exceptions thrown during processing
of nested #parse() calls do not get passed to the calling code. It is very simple to reproduce
- just compile the following and set up a couple of test files.
> 
> Test program source:
> 
> public class Test
> {
>    public static void main(String[] args)
>    {
>        try
>        {
>            String resource = args[0];
>            VelocityContext context = new VelocityContext(new Properties());
>            context.put("firstName", "Pete");
>            VelocityEngine ve = new VelocityEngine();
>            Properties velCfg = new Properties();
>            ve.init(velCfg);
>            Writer w = new StringWriter();
>            ve.mergeTemplate(resource, context, w);
>            System.out.println(w.toString());
>        }
>        catch (Exception e)
>        {
>            e.printStackTrace();
>        }
>    }
> }
> 
> test file 1 ("basic.txt"):
> 
> #parse( "no-such-file.txt" )
> 
> test file 2 ("wrapper.txt"):
> 
> #parse( "basic.txt" )
> 
> Now run the program using "basic.txt" as the argument; you'll see an exception thrown
because the engine can't find "no-such-file.txt". So far so good.
> 
> Run it again using "wrapper.txt" as the argument; this time no exception is thrown. The
mergeTemplate() call returns to the caller as if nothing is wrong.
> 

If you look in to the Velocity.log, it does throw an
ResourceNotFoundException and ignores what ever comes in the template
after that exception.

Thanks,
Kishore Senji

> This is causing me serious headaches and I have to find a solution or workround. Is this
a known bug? Does anyone know of a fix?
> 
> I'm running on RedHat 9. Velocity 1.3.1 and 1.4 both behave the same way.
> 
> --Pete
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message