You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2008/08/29 07:25:24 UTC

svn commit: r690109 - /servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/NormalizedMessageImpl.java

Author: ffang
Date: Thu Aug 28 22:25:23 2008
New Revision: 690109

URL: http://svn.apache.org/viewvc?rev=690109&view=rev
Log:
[SM-1526,1436]check if map entry is serializable before serialize the map

Modified:
    servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/NormalizedMessageImpl.java

Modified: servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/NormalizedMessageImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/NormalizedMessageImpl.java?rev=690109&r1=690108&r2=690109&view=diff
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/NormalizedMessageImpl.java (original)
+++ servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/NormalizedMessageImpl.java Thu Aug 28 22:25:23 2008
@@ -21,6 +21,7 @@
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+import java.io.Serializable;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -308,7 +309,10 @@
         try {
             convertAttachments();
             out.writeObject(attachments);
-            out.writeObject(properties);
+            //since we can't guarantee all properties is Serializable, so only write the
+            //properties which is serializable to the external to avoid NotSerializableException
+            Map serialiableProperties = getSeriableProperties(properties);
+            out.writeObject(serialiableProperties);
             String src = TRANSFORMER.toString(content);
             out.writeObject(src);
             // We have read the source
@@ -322,6 +326,20 @@
         }
     }
 
+    private Map getSeriableProperties(Map originalProperties) {
+        if (originalProperties == null) {
+            return originalProperties;
+        }
+        Map ret = new HashMap();
+        for (Object key : originalProperties.keySet()) {
+            if (originalProperties.get(key) instanceof Serializable) {
+                ret.put(key, originalProperties.get(key));
+            }
+        }
+        return ret;
+    }
+ 
+   
     private void convertAttachments() throws IOException {
         if (attachments != null) {
             Map newAttachments = createAttachmentsMap();