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:22:26 UTC
svn commit: r690108 -
/servicemix/smx3/branches/servicemix-3.2/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/NormalizedMessageImpl.java
Author: ffang
Date: Thu Aug 28 22:22:25 2008
New Revision: 690108
URL: http://svn.apache.org/viewvc?rev=690108&view=rev
Log:
[SM-1526,1436]check if map entry is serializable before serialize the map
Modified:
servicemix/smx3/branches/servicemix-3.2/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/NormalizedMessageImpl.java
Modified: servicemix/smx3/branches/servicemix-3.2/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/NormalizedMessageImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/NormalizedMessageImpl.java?rev=690108&r1=690107&r2=690108&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/NormalizedMessageImpl.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/NormalizedMessageImpl.java Thu Aug 28 22:22:25 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();