camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Weird and unexpected behavior.
Date Tue, 03 Apr 2012 14:46:05 GMT
Hi

Read about stream caching
http://camel.apache.org/stream-caching.html

We have a notice on the jetty page
http://camel.apache.org/jetty.html

We should have that notice on the servlet as well, as most servlet
implementations is also stream based.


On Tue, Apr 3, 2012 at 4:39 PM, Knut Aksnes-NOR
<Knut.Aksnes@jeppesen.com> wrote:
> In one of my routes I have seen a for me at least extremely strange behavior. It is either
a bug or a potentially very dangerous feature.
> First some background:
>        1. I am running Camel 2.9.1 from using war packaging and Geronimo 2.2.1 with
Jetty.
>        2. The source of my problem route is a servlet.
>        3. The requests arrive via http post and are binary data.
>        4. I have written a small helper processor shown here:
>
> public static final class BodyDebugger implements Processor {
>                final String text;
>
>                public BodyDebugger(String arg) {
>                        text = arg;
>                }
>
>                @Override
>                public void process(Exchange exchange) throws Exception {
>                        byte[] body = exchange.getIn().getBody(byte[].class);
>                        LogFactory.getLog(getClass()).warn(
>                                        text
>                                                        +
": "
>                                                        +
(body == null ? "(NULL)" : Integer
>                                                          
             .toString(body.length)));
>                }
>        }
>
> It's only purpose is to convert the data to byte[] and show the array length. I do this
conversion as I need the data block as byte array at a later stage (As input to another route,
this time using ActiveMQ.)
>
> Now to the strange behavior: Invoking this processor twice in a row this way .process(new
BodyDebugger("Foo")).process(new BodyDebugger("Bar") results in two different results the
first one might be correct, the second time around the body length is 0, that is a body consisting
of an empty array, not the null pointer.



-- 
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Mime
View raw message