I've just faced an interesting issue with a StreamCache body being
'exausted' after calling exchange.getIn().getBody(String.class) inside an
EventNotifier

I'm using Camel 2.10.0 (inside JBoss Fuse 6.0) and captured an
ExchangeCreatedEvent on a HTTP endpoint (input). The payload was an
instance of InputStreamCache and after the EventNotifier executed I got a
'Premature End of File' trying to parse the body as xml in the pipeline.

Looking at the source code of InputStreamCache (extends
ByteArrayInputStream) the writeTo method uses IOHelper.copy which
'consumes' the underlying byte array, so a next call would throw some
IOException. I reckon this behaviour is correct according to the interface
StreamCache.

What I wonder is whether the automatic TypeConversion should (or not) try
to reset() the StreamCache after doing the type conversion, avoiding such
situations.

Does this make sense? Is this fixed in the latest versions or I should
raise a JIRA?

Regards,
Henrique Viecili

Reply via email to