Return-Path: Delivered-To: apmail-activemq-camel-commits-archive@locus.apache.org Received: (qmail 81845 invoked from network); 14 Jul 2008 16:51:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Jul 2008 16:51:19 -0000 Received: (qmail 14037 invoked by uid 500); 14 Jul 2008 16:51:19 -0000 Delivered-To: apmail-activemq-camel-commits-archive@activemq.apache.org Received: (qmail 14018 invoked by uid 500); 14 Jul 2008 16:51:19 -0000 Mailing-List: contact camel-commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: camel-dev@activemq.apache.org Delivered-To: mailing list camel-commits@activemq.apache.org Received: (qmail 14009 invoked by uid 99); 14 Jul 2008 16:51:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Jul 2008 09:51:19 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Jul 2008 16:50:34 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B651C2388A1B; Mon, 14 Jul 2008 09:50:28 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r676641 - /activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java Date: Mon, 14 Jul 2008 16:50:28 -0000 To: camel-commits@activemq.apache.org From: jstrachan@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080714165028.B651C2388A1B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jstrachan Date: Mon Jul 14 09:50:27 2008 New Revision: 676641 URL: http://svn.apache.org/viewvc?rev=676641&view=rev Log: avoid NullPointerException if no CamelContext set on an Exchange Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java?rev=676641&r1=676640&r2=676641&view=diff ============================================================================== --- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java (original) +++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java Mon Jul 14 09:50:27 2008 @@ -19,6 +19,7 @@ import org.apache.camel.Exchange; import org.apache.camel.Message; import org.apache.camel.TypeConverter; +import org.apache.camel.CamelContext; import org.apache.camel.util.UuidGenerator; /** @@ -52,16 +53,19 @@ protected T getBody(Class type, Object body) { Exchange e = getExchange(); if (e != null) { - TypeConverter converter = e.getContext().getTypeConverter(); - T answer = converter.convertTo(type, body); - if (answer == null) { - // lets first try converting the message itself first - // as for some types like InputStream v Reader its more efficient to do the transformation - // from the Message itself as its got efficient implementations of them, before trying the - // payload - answer = converter.convertTo(type, this); + CamelContext camelContext = e.getContext(); + if (camelContext != null) { + TypeConverter converter = camelContext.getTypeConverter(); + T answer = converter.convertTo(type, body); + if (answer == null) { + // lets first try converting the message itself first + // as for some types like InputStream v Reader its more efficient to do the transformation + // from the Message itself as its got efficient implementations of them, before trying the + // payload + answer = converter.convertTo(type, this); + } + return answer; } - return answer; } return (T)getBody(); }