You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Lamb, Doug" <DN...@ingersoll-imc.com> on 2001/11/05 18:00:35 UTC

RE: Velocity exits foreach loop in macro unpredictably, both 1.1 and 1.2-dev

Maybe I'm way off here, but it doesn't sound like Velocity is the problem to
me.  I would be suspicious of the getStoredData() method in the event
object.  I would try and isolate this by making getStoredData() simply
return a literal String and see if the problem goes away.

Just a thought,

Doug



-----Original Message-----
From: Nick Bauman [mailto:nick@cortexity.com]
Sent: Monday, November 05, 2001 9:25 AM
To: velocity-user@jakarta.apache.org
Subject: Velocity exits foreach loop in macro unpredictably, both 1.1
and 1.2-dev


Forgive me my inability to come up with a consise example of how to
reproduce the error, if I had one I probably could have fixed it myself. I
can't force this to reproduce itself except under our load testing
environment at my company. I'm now working to consisely reproduce the
problem in another contrived situation. I'm asking the community if anything
 I'm showing "rings a bell" to a problem.

We use Velocity as a mail templating system. We recently discovered that in
thousands of requests over a period of 5 minutes, the resulting merge()
calls yield mysteriously incomplete emails. No exceptions are thrown,
everything appears fine in the logs. 

Our typical template looks like this:

-----8<-----

#* $Id: Texten_msftrxbx.vtl,v 1.1 2001/11/05 15:06:40 hvanlaar Exp $ *#
#parse ( "functions.vtl" )

$queue.getEmailSubject()

Thank you for using Acme Center. Below is a copy of your chat session
transcript for reference.

Topic: $!meeting.getTopic()

#drawStandardTextTranscript( $meeting )

==========
$!repId:$meeting.getMeetingId()

-----8<-----

the parsed template, entitled "functions.vtl" looks like this:

-----8<-----

...[other stuff]...

#macro( drawStandardTextTranscript $meeting )
#foreach( $event in $meeting.getAllEvents() )
#set( $yapper = $meeting.getParticipation($event.getFromId()) )
#if( $event.getClass().getName().equals($urlEvent) )
$yapper.getName(): $event.getStoredData()
#elseif( $event.getClass().getName().equals($chatEvent) )
#if($repRole.equals($yapper.getRole()) )
#set( $repId = $yapper.getParticipantId() )
#end
$yapper.getName(): $event.getStoredData()
#end
#end
#end

...[other stuff]...

-----8<-----

The problem is the resulting output ocassionally (5-25% of the time) will
not contain all $event.getStoredData() that it should. However, all the
other stuff in the template will look fine: the footer and everything else.
So, for some of the mails, there should be 15 lines of text, but we only see
one or two. It's very strange and I cannot reproduce it outside of our load
environment.

Question is: is it possible some wierd threading behavior is ocurring? I'm
not reusing a new VelocityContext for each call to merge() I'm making a new
one each time. All other settings in Velocity are default except the
template root, which I define.

Thanks for any insights.


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Velocity exits foreach loop in macro unpredictably, both 1.1

Posted by Nick Bauman <ni...@cortexity.com>.
Okay, hours later and tweaking the load test environment parameters around 
and we can get the same kinds of failures, with the same frequency as we 
could with caching turned off, so ResourceLoader caching is a red herring.

Since I'm ready to punt in making a contrived example fail predictably, I'm 
going to convert the macro call into a context tool (to get the problem out 
of Velocity) and hand that to load testing and see what comes out.

Will report back. Thanks everyone!

> Maybe I'm way off here, but it doesn't sound like Velocity is the
> problem to me.  I would be suspicious of the getStoredData() method in
> the event object.  I would try and isolate this by making
> getStoredData() simply return a literal String and see if the problem
> goes away.
> 
> Just a thought,
> 
> Doug
> 
> 
> 
> -----Original Message-----
> From: Nick Bauman [mailto:nick@cortexity.com]
> Sent: Monday, November 05, 2001 9:25 AM
> To: velocity-user@jakarta.apache.org
> Subject: Velocity exits foreach loop in macro unpredictably, both 1.1
> and 1.2-dev
> 
> 
> Forgive me my inability to come up with a consise example of how to
> reproduce the error, if I had one I probably could have fixed it
> myself. I can't force this to reproduce itself except under our load
> testing environment at my company. I'm now working to consisely
> reproduce the problem in another contrived situation. I'm asking the
> community if anything
>  I'm showing "rings a bell" to a problem.
> 
> We use Velocity as a mail templating system. We recently discovered
> that in thousands of requests over a period of 5 minutes, the resulting
> merge() calls yield mysteriously incomplete emails. No exceptions are
> thrown, everything appears fine in the logs. 
> 
> Our typical template looks like this:
> 
> -----8<-----
> 
> #* $Id: Texten_msftrxbx.vtl,v 1.1 2001/11/05 15:06:40 hvanlaar Exp $ *#
> #parse ( "functions.vtl" )
> 
> $queue.getEmailSubject()
> 
> Thank you for using Acme Center. Below is a copy of your chat session
> transcript for reference.
> 
> Topic: $!meeting.getTopic()
> 
> #drawStandardTextTranscript( $meeting )
> 
> ==========
> $!repId:$meeting.getMeetingId()
> 
> -----8<-----
> 
> the parsed template, entitled "functions.vtl" looks like this:
> 
> -----8<-----
> 
> ...[other stuff]...
> 
> #macro( drawStandardTextTranscript $meeting )
> #foreach( $event in $meeting.getAllEvents() )
> #set( $yapper = $meeting.getParticipation($event.getFromId()) )
> #if( $event.getClass().getName().equals($urlEvent) )
> $yapper.getName(): $event.getStoredData()
> #elseif( $event.getClass().getName().equals($chatEvent) )
> #if($repRole.equals($yapper.getRole()) )
> #set( $repId = $yapper.getParticipantId() )
> #end
> $yapper.getName(): $event.getStoredData()
> #end
> #end
> #end
> 
> ...[other stuff]...
> 
> -----8<-----
> 
> The problem is the resulting output ocassionally (5-25% of the time)
> will not contain all $event.getStoredData() that it should. However,
> all the other stuff in the template will look fine: the footer and
> everything else. So, for some of the mails, there should be 15 lines of
> text, but we only see one or two. It's very strange and I cannot
> reproduce it outside of our load environment.
> 
> Question is: is it possible some wierd threading behavior is ocurring?
> I'm not reusing a new VelocityContext for each call to merge() I'm
> making a new one each time. All other settings in Velocity are default
> except the template root, which I define.
> 
> Thanks for any insights.
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org> For additional
> commands, e-mail: <ma...@jakarta.apache.org>


-- 
Those willing to give up a little freedom for a little bread are likely to 
lose both. --Sidney Crooke, American Abolitionist


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>