If you consume the stream by calling the getBody(String.class), you need to call the reset method of the StreamCache. Can you show me the camel route that you have?
-- Willem Jiang Red Hat, Inc. Web: http://www.redhat.com Blog: http://willemjiang.blogspot.com (English) http://jnn.iteye.com (Chinese) Twitter: willemjiang Weibo: 姜宁willem On April 14, 2014 at 11:57:52 AM, Henrique Viecili (viec...@gmail.com) wrote: > 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 >