Behavior of Servlet output in Groovy 1.8.4 & Gaelyk 1.0

14 views
Skip to first unread message

John

unread,
Dec 20, 2011, 2:31:56 PM12/20/11
to gae...@googlegroups.com
I've just encountered a situation where the response body from my Gaelyk script is cut off in a way that looks like the buffer of the ServletOutput (Gaelyk out variable) isn't flushed. The situation that produces the failure hasn't happened on the SDK server (only when deployed on Appengine, so far), so I'm can't say with certainty where the problem lies. I'm suspicious because we were running with Groovy 1.7.6 and Gaelyk 0.7.? until recently and didn't see this behavior.

Curious if anyone has suggestions on where to look for the problem.

Thanks!
John

Guillaume Laforge

unread,
Dec 20, 2011, 2:54:18 PM12/20/11
to gae...@googlegroups.com
Hi John,

The CacheHandler class is responsible for the caching of your groovlet and template outputs:

It hasn't really changed much since the days of 0.7, so I don't see how things could be different from then.

The CacheHandler is called from the RoutesFilter:

You could try building a custom Gaelyk version with a few log statements here and there to see what's going on?
Perhaps you can try adding some response.outputStream.flush() calls in CacheHandler, and see what's happening.

Anyhow, so far, I'm not really aware of any buffer size / flushing issue.

Guillaume


John

--
You've received this message because you've subscribed to the Gaelyk Google Group.
To send an email to the group, please write to: gae...@googlegroups.com
To unsuscribe from this group: gaelyk+un...@googlegroups.com
To show more options: http://groups.google.fr/group/gaelyk?hl=en



--
Guillaume Laforge
Groovy Project Manager
SpringSource, a division of VMware


John

unread,
Dec 20, 2011, 5:37:55 PM12/20/11
to gae...@googlegroups.com
Thanks for the quick response, Guilllaume!

This looks pretty weird: The first time the script is run, the output is complete (2787 chars). Later, when the output is slightly different, the script is run 3 times in sequence, and the output is truncated to 2307 chars the first time, 2310 chars the second time and 2313 chars the third time. Don't remember ever seeing a bug that increments by 3, before :>

We never specify cache in routes.groovy, so I hope the output wouldn't be affected by the cache holding a prior value. I suppose it's possible that the output is actually 2307 chars (then 2310, then 2313), and the first (2787 char result) is being sent in the response, truncated to the actual length that the script produced.

I still haven't made it happen in the SDK dev server, so I suppose I'll see whether I can change the behavior by adding a flush() call.  I guess there isn't logging to enable in the flow of the Cache / ServletOutput...

I'll pull down the Gaelyk 1.0 source.  Things have been working nicely, so my copy of the source is still at 17 October.

John

unread,
Dec 20, 2011, 11:52:36 PM12/20/11
to gae...@googlegroups.com
Was I mistaken to think the infrastructure would flush the response's writer? I added out.flush() in the script where we noticed the problem and it hasn't happened since. I did a little tracing and saw that the template handler calls flush() on the ServletBinding's ServletOutput, but the groovy (groovlet) script, neither flush() nor close() was called on that class.

Our code is making use of the out binding (response.writer) and we hadn't seen anything that looked like an incomplete response before moving to Groovy 1.8.4 / Gaelyk 1.0. After looking at the source, the way we're doing things, there isn't much Gaelyk involved, so I'll probably raise the question on user@groovy. Unfortunately, I still don't have a way to reproduce the problem.

Guillaume Laforge

unread,
Dec 21, 2011, 3:14:30 AM12/21/11
to gae...@googlegroups.com
Hmm okay, I thought you were using the caching from the routing system, so forget about my previous comments!

--
You've received this message because you've subscribed to the Gaelyk Google Group.
To send an email to the group, please write to: gae...@googlegroups.com
To unsuscribe from this group: gaelyk+un...@googlegroups.com
To show more options: http://groups.google.fr/group/gaelyk?hl=en

Guillaume Laforge

unread,
Dec 21, 2011, 3:16:36 AM12/21/11
to gae...@googlegroups.com
I'd expect the "infrastructure", as you say, to flush the response where appropriate.
So I would expect explicit flushes to not be needed but who knows...


On Wed, Dec 21, 2011 at 05:52, John <jwb...@gmail.com> wrote:
Was I mistaken to think the infrastructure would flush the response's writer? I added out.flush() in the script where we noticed the problem and it hasn't happened since. I did a little tracing and saw that the template handler calls flush() on the ServletBinding's ServletOutput, but the groovy (groovlet) script, neither flush() nor close() was called on that class.

Our code is making use of the out binding (response.writer) and we hadn't seen anything that looked like an incomplete response before moving to Groovy 1.8.4 / Gaelyk 1.0. After looking at the source, the way we're doing things, there isn't much Gaelyk involved, so I'll probably raise the question on user@groovy. Unfortunately, I still don't have a way to reproduce the problem.

--
You've received this message because you've subscribed to the Gaelyk Google Group.
To send an email to the group, please write to: gae...@googlegroups.com
To unsuscribe from this group: gaelyk+un...@googlegroups.com
To show more options: http://groups.google.fr/group/gaelyk?hl=en

John

unread,
Dec 22, 2011, 12:29:22 AM12/22/11
to gae...@googlegroups.com
Seems not to be a problem with the Groovy code. The client is most likely dropping the connection before the end of the response.

Guillaume Laforge

unread,
Dec 22, 2011, 2:10:14 AM12/22/11
to gae...@googlegroups.com
I prefer that :-)

Guillaume

Le 22 déc. 2011 à 06:29, John <jwb...@gmail.com> a écrit :

Seems not to be a problem with the Groovy code. The client is most likely dropping the connection before the end of the response.

--
Reply all
Reply to author
Forward
0 new messages