velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ford, Peter" <Peter.F...@travelocity.com>
Subject RE: Bug in nested #parse()
Date Fri, 13 Aug 2004 12:53:02 GMT
Yes, I saw that the log captures the error - but that doesn't fix the problem. With the exception
not reaching the calling code, it assumes everything is ok when it isn't; as a result, the
partially-processed output is used as if everything was good.

--Pete

> -----Original Message-----
> From: Kishore Senji [mailto:ksenji@gmail.com]
> Sent: Thursday, August 12, 2004 4:02 PM
> To: Velocity Users List
> Subject: Re: Bug in nested #parse()
> 
> 
> 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
> 
> 

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