camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "raulvk.soa" <raulvk....@gmail.com>
Subject Bug in LogFormatter.getBodyTypeAsString
Date Tue, 23 Sep 2008 10:58:41 GMT

Hi,

Sometimes, the "in" message of an exchange can be null. I have come across
such case when communicating over a JBI endpoint, and during the processing
within ServiceMix an internal error occurs. JBI returns a null "out" message
on an InOut exchange, and Camel's Pipeline takes this null "out" message and
sets it as the new "in" message, thus effectively setting the "in" message
as null.

If the next endpoint is a Log component, this is what happens:

11:48:29,396 | ERROR - org.apache.camel.processor.Logger - Failed delivery
for exchangeId: ID-XXX-B624E47AF0/4985-1222164544269/0-172. On delivery
attempt: 5 caught: java.lang.NullPointerException
java.lang.NullPointerException
        at
org.apache.camel.component.log.LogFormatter.getBodyTypeAsString(LogFormatter.java:167)
        at
org.apache.camel.component.log.LogFormatter.format(LogFormatter.java:56)
        at org.apache.camel.processor.Logger.logMessage(Logger.java:218)
        at org.apache.camel.processor.Logger.process(Logger.java:88)
        ................

I believe that logging methods should be non-intrusive, so we should first
check whether variables are null before accessing them, as it is not
acceptable for a logging task to interrupt the pipeline. In this case, my
suggestion is that if BodyType == null, then just print the string
"BodyType: null".

Cheers.
-- 
View this message in context: http://www.nabble.com/Bug-in-LogFormatter.getBodyTypeAsString-tp19625342s22882p19625342.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message