camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r832702 - /camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
Date Wed, 04 Nov 2009 10:44:37 GMT
Author: davsclaus
Date: Wed Nov  4 10:44:28 2009
New Revision: 832702

URL: http://svn.apache.org/viewvc?rev=832702&view=rev
Log:
CAMEL-2132: jms producer sending Object should madatory convert to serializable and throw
exception if not possible.

Modified:
    camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java

Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java?rev=832702&r1=832701&r2=832702&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
(original)
+++ camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
Wed Nov  4 10:44:28 2009
@@ -32,6 +32,7 @@
 import javax.jms.JMSException;
 import javax.jms.MapMessage;
 import javax.jms.Message;
+import javax.jms.MessageFormatException;
 import javax.jms.ObjectMessage;
 import javax.jms.Session;
 import javax.jms.StreamMessage;
@@ -41,6 +42,7 @@
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
+import org.apache.camel.NoTypeConversionAvailableException;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.StreamCache;
 import org.apache.camel.component.file.GenericFile;
@@ -475,7 +477,15 @@
                 return message;
             }
             case Object:
-                Serializable payload = context.getTypeConverter().convertTo(Serializable.class,
exchange, body);
+                Serializable payload;
+                try {
+                    payload = context.getTypeConverter().mandatoryConvertTo(Serializable.class,
exchange, body);
+                } catch (NoTypeConversionAvailableException e) {
+                    // cannot convert to serializable then thrown an exception to avoid sending
a null message
+                    JMSException cause = new MessageFormatException(e.getMessage());
+                    cause.initCause(e);
+                    throw cause;
+                }
                 return session.createObjectMessage(payload);
             default:
                 break;



Mime
View raw message