You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ff...@apache.org on 2008/09/02 10:25:40 UTC

svn commit: r691148 - /cxf/trunk/rt/transports/jbi/src/main/java/org/apache/cxf/transport/jbi/JBIDestinationOutputStream.java

Author: ffang
Date: Tue Sep  2 01:25:39 2008
New Revision: 691148

URL: http://svn.apache.org/viewvc?rev=691148&view=rev
Log:
[CXF-1779]exclude non-serializable property to JBI NormalizedMessage

Modified:
    cxf/trunk/rt/transports/jbi/src/main/java/org/apache/cxf/transport/jbi/JBIDestinationOutputStream.java

Modified: cxf/trunk/rt/transports/jbi/src/main/java/org/apache/cxf/transport/jbi/JBIDestinationOutputStream.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jbi/src/main/java/org/apache/cxf/transport/jbi/JBIDestinationOutputStream.java?rev=691148&r1=691147&r2=691148&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jbi/src/main/java/org/apache/cxf/transport/jbi/JBIDestinationOutputStream.java (original)
+++ cxf/trunk/rt/transports/jbi/src/main/java/org/apache/cxf/transport/jbi/JBIDestinationOutputStream.java Tue Sep  2 01:25:39 2008
@@ -21,6 +21,7 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.Serializable;
 import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -113,7 +114,9 @@
                     //copy properties
                     Set<String> keys = inMessage.keySet();
                     for (String key : keys) {
-                        msg.setProperty(key, inMessage.get(key));
+                        if (inMessage.get(key) instanceof Serializable) {
+                            msg.setProperty(key, inMessage.get(key));
+                        }
                     }
                     //copy contents
                     msg.setContent(new DOMSource(doc));



Re: svn commit: r691148 - /cxf/trunk/rt/transports/jbi/src/main/java/org/apache/cxf/transport/jbi/JBIDestinationOutputStream.java

Posted by Freeman Fang <fr...@gmail.com>.
Hi Dan,

You are correct, we needn't lookup operation in this case, just copy the 
entry which is serializable, I will refactor code according to your 
suggestion.

Thanks

Freeman

Daniel Kulp wrote:
> Freeman,
>
> On Tuesday 02 September 2008 4:25:40 am ffang@apache.org wrote:
>   
>>                      //copy properties
>>                      Set<String> keys = inMessage.keySet();
>>                      for (String key : keys) {
>> -                        msg.setProperty(key, inMessage.get(key));
>> +                        if (inMessage.get(key) instanceof Serializable) {
>> +                            msg.setProperty(key, inMessage.get(key));
>> +                        }
>>                      }
>>     
>
> Just a quick code suggestion....
>
> If you are interested in both the Key and the Value, it is much faster to use 
> the entryset instead of the keyset and then re-lookup each value by key:
>
>
> for (Map.Entry<String, Object> ent : inMessage.entrySet()) {
>       if (ent.getValue() instanceof Serializable) {
>            msg.setProperty(ent.getKey(), ent.getValue());
>       }
> }
>
> It avoids the hashtable lookup for each value.
>
>   


Re: svn commit: r691148 - /cxf/trunk/rt/transports/jbi/src/main/java/org/apache/cxf/transport/jbi/JBIDestinationOutputStream.java

Posted by Daniel Kulp <dk...@apache.org>.
Freeman,

On Tuesday 02 September 2008 4:25:40 am ffang@apache.org wrote:
>                      //copy properties
>                      Set<String> keys = inMessage.keySet();
>                      for (String key : keys) {
> -                        msg.setProperty(key, inMessage.get(key));
> +                        if (inMessage.get(key) instanceof Serializable) {
> +                            msg.setProperty(key, inMessage.get(key));
> +                        }
>                      }

Just a quick code suggestion....

If you are interested in both the Key and the Value, it is much faster to use 
the entryset instead of the keyset and then re-lookup each value by key:


for (Map.Entry<String, Object> ent : inMessage.entrySet()) {
      if (ent.getValue() instanceof Serializable) {
           msg.setProperty(ent.getKey(), ent.getValue());
      }
}

It avoids the hashtable lookup for each value.

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog