Thanks, Thierry.

I don't use eclipse, but when I have some time, I'll cobble together a
build.xml and confirm that your two examples run in snapshot (and 2.1-M2),
then I'll see if my code works with auto-close disabled and no flush
suppression in snapshot. I'll also see if Jackson 1.7.2 changes my observed
behavior.

But it'll be a few days. :-(

--tim

On Wed, Feb 9, 2011 at 10:03 AM, Thierry Boileau <
[email protected]> wrote:

> Hello Tim,
>
> I've just made some tests using a standalone and servlet-based app (hosted
> in Tomcat 6.0.32) using the current snapshot. It works well for me using the
> internal client connector, except that the client code hangs after the last
> operation (whatever it is). It is possible to get, put data correctly from
> and to the server.
> I send you my sample code (2 eclipse projects, the client code is located
> in the "testJackson" project).
> Could you try with the current snapshot (libraries are also in the attached
> file).
>
> Best regards,
> Thierry Boileau
>
>
> [Restlet 2.1-M2 jse/jee editions, Jackson 1.7.1. Posting to discussion list
>> because it refers to another message in the same list. I'll repost to code
>> list if folks think it belongs there instead.]
>>
>> Class JacksonRepresentation (from Restlet's Jackson extension) creates an
>> ObjectMapper with the AUTO_CLOSE_TARGET disabled. I extended
>> JacksonRepresentation to override createObjectMapper in order to do my own
>> configuration, and I unintentionally left off this disable call.
>>
>> It worked just fine, though, within a Restlet Component running
>> standalone. When I recently tried to run the Component within ServerServlet
>> (in Tomcat 6), however, I got the stack trace reported in this thread:
>>
>>
>> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2436859
>>
>> Disabling AUTO_CLOSE_TARGET didn't fix it -- instead of the error the
>> server just hangs (in standalone mode, at least).
>>
>> I looked hard at the stack trace above and decided to try leaving
>> auto-close enabled and suppressing the final flush() in
>> WriterRepresentation.write(OutputStream). This worked. I don't get the
>> exception any more, and I *do* get the JSON content. The standalone
>> Component doesn't require the flush, either.
>>
>> I can't say for sure that leaving AUTO_CLOSE_TARGET enabled and
>> suppressing the final flush in WriterRepresentation is really the right
>> thing to do, but it's the only combination that works for me in both servlet
>> and standalone settings.
>>
>> I suppressed the flush by overriding write(OutputStream) in my
>> JacksonRepresentation subclass, but maybe WriterRepresentation should have a
>> setting for this, e.g.:
>>
>>     WriterRepresentation rep = new JacksonRepresentation(...);
>>     rep.setFlushAfterWrite(false);
>>     ...
>>
>> And if the auto-close-enabled and no-flush-after-write combination *is*
>> deemed the right thing to do, that could be the default for
>> JacksonRepresentation, and you could remove the auto-close disable logic
>> from JacksonRepresentation.createObjectMapper.
>>
>> --tim
>>
>>
>

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2703029

Reply via email to