You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by dermoritz <ta...@hotmail.com> on 2014/11/28 10:31:33 UTC

Lately (2.14) NullPointerExceptions instead of TypeConversionExceptions

Some day ago i switched to camel 2.14 (mainly because of RoutePolicyFactory -
a great idea!). But i also noticed on creating new routes with new
processors/ aggregators i see many NullPointerExceptions in lines that use
object from exchange.getIn().getBody(Some.class).
In those cases the body was never empty (debugged it) but the type
conversion was not possible. As soon as i use the correct type or use it
without class parameter the NPEs are gone.

The problem is that i often catch the TypeConversionException and rethrow it
to give additional info. Should i change that code and catch NPE instead?
Could this be related with 2.14? 

Thanks in advance



--
View this message in context: http://camel.465427.n5.nabble.com/Lately-2-14-NullPointerExceptions-instead-of-TypeConversionExceptions-tp5759751.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Lately (2.14) NullPointerExceptions instead of TypeConversionExceptions

Posted by dermoritz <ta...@hotmail.com>.
Probably the stacktrace will not help: the npe is thrown on the line where i
use the object returned from getBody(Some.class);

The problem ist that no exception is thrown by getBody(Some.class) but null
is returned. So there must be a path that returns null.



--
View this message in context: http://camel.465427.n5.nabble.com/Lately-2-14-NullPointerExceptions-instead-of-TypeConversionExceptions-tp5759751p5760690.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Lately (2.14) NullPointerExceptions instead of TypeConversionExceptions

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Can you paste the stacktrace where you get the NPE ?

On Fri, Nov 28, 2014 at 10:31 AM, dermoritz <ta...@hotmail.com> wrote:
> Some day ago i switched to camel 2.14 (mainly because of RoutePolicyFactory -
> a great idea!). But i also noticed on creating new routes with new
> processors/ aggregators i see many NullPointerExceptions in lines that use
> object from exchange.getIn().getBody(Some.class).
> In those cases the body was never empty (debugged it) but the type
> conversion was not possible. As soon as i use the correct type or use it
> without class parameter the NPEs are gone.
>
> The problem is that i often catch the TypeConversionException and rethrow it
> to give additional info. Should i change that code and catch NPE instead?
> Could this be related with 2.14?
>
> Thanks in advance
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Lately-2-14-NullPointerExceptions-instead-of-TypeConversionExceptions-tp5759751.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/