You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Christian Müller (JIRA)" <ji...@apache.org> on 2012/06/06 10:25:23 UTC

[jira] [Created] (CAMEL-5338) Exchange.copy() should make a deep copy, if the referenced objects (body, headers, properties) implements java.lang.Cloneable

Christian Müller created CAMEL-5338:
---------------------------------------

             Summary: Exchange.copy() should make a deep copy, if the referenced objects (body, headers, properties) implements java.lang.Cloneable
                 Key: CAMEL-5338
                 URL: https://issues.apache.org/jira/browse/CAMEL-5338
             Project: Camel
          Issue Type: Improvement
    Affects Versions: 2.9.2
            Reporter: Christian Müller
             Fix For: 2.9.3, 2.10.1, 2.11


We run into an issue where an exchange with a custom pojo as payload was sent to an multicast and changed in two different sub-routes at the same time (connected by using the direct protocol). The reason is that the Exchange.copy() method "only" creates shallow copies of the body (it's the same for the exchange properties and message headers). I think it's a good improvement to check whether the object implements java.lang.Cloneable and in this case create a deep copy of the object.  

[1] https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
[2] https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Updated] (CAMEL-5338) Exchange.copy() should make a deep copy, if the referenced objects (body, headers, properties) implements java.lang.Cloneable

Posted by "Christian Müller (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-5338?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Christian Müller updated CAMEL-5338:
------------------------------------

    Fix Version/s:     (was: 2.11)
                       (was: 2.10.1)
                       (was: 2.9.3)
                   3.0.0
    
> Exchange.copy() should make a deep copy, if the referenced objects (body, headers, properties) implements java.lang.Cloneable
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-5338
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5338
>             Project: Camel
>          Issue Type: Improvement
>    Affects Versions: 2.9.2
>            Reporter: Christian Müller
>             Fix For: 3.0.0
>
>
> We run into an issue where an exchange with a custom pojo as payload was sent to an multicast and changed in two different sub-routes at the same time (connected by using the direct protocol). The reason is that the Exchange.copy() method "only" creates shallow copies of the body (it's the same for the exchange properties and message headers). I think it's a good improvement to check whether the object implements java.lang.Cloneable and in this case create a deep copy of the object.  
> [1] https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
> [2] https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (CAMEL-5338) Exchange.copy() should make a deep copy, if the referenced objects (body, headers, properties) implements java.lang.Cloneable

Posted by "Christian Müller (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-5338?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13291183#comment-13291183 ] 

Christian Müller commented on CAMEL-5338:
-----------------------------------------

Thanks for the hint Claus, but unfortunately we stick with Camel 2.6 (ServiceMix 4.3) for this application. We found a solution / workaround for it ...

I'm ok to move it to 3.0.
I'm wondering what's the downside of checking whether the Object implements Cloneable and call clone()? In this case it's the responsibility of the user to implement clone() in the right way. And the user is the one who should know how to do it in the right way.
                
> Exchange.copy() should make a deep copy, if the referenced objects (body, headers, properties) implements java.lang.Cloneable
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-5338
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5338
>             Project: Camel
>          Issue Type: Improvement
>    Affects Versions: 2.9.2
>            Reporter: Christian Müller
>             Fix For: 3.0.0
>
>
> We run into an issue where an exchange with a custom pojo as payload was sent to an multicast and changed in two different sub-routes at the same time (connected by using the direct protocol). The reason is that the Exchange.copy() method "only" creates shallow copies of the body (it's the same for the exchange properties and message headers). I think it's a good improvement to check whether the object implements java.lang.Cloneable and in this case create a deep copy of the object.  
> [1] https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
> [2] https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (CAMEL-5338) Exchange.copy() should make a deep copy, if the referenced objects (body, headers, properties) implements java.lang.Cloneable

Posted by "Christian Müller (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-5338?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13402578#comment-13402578 ] 

Christian Müller commented on CAMEL-5338:
-----------------------------------------

Copy Constructor versus Cloning: http://www.artima.com/intv/bloch13.html
                
> Exchange.copy() should make a deep copy, if the referenced objects (body, headers, properties) implements java.lang.Cloneable
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-5338
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5338
>             Project: Camel
>          Issue Type: Improvement
>    Affects Versions: 2.9.2
>            Reporter: Christian Müller
>             Fix For: 3.0.0
>
>
> We run into an issue where an exchange with a custom pojo as payload was sent to an multicast and changed in two different sub-routes at the same time (connected by using the direct protocol). The reason is that the Exchange.copy() method "only" creates shallow copies of the body (it's the same for the exchange properties and message headers). I think it's a good improvement to check whether the object implements java.lang.Cloneable and in this case create a deep copy of the object.  
> [1] https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
> [2] https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (CAMEL-5338) Exchange.copy() should make a deep copy, if the referenced objects (body, headers, properties) implements java.lang.Cloneable

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-5338?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13402887#comment-13402887 ] 

Claus Ibsen commented on CAMEL-5338:
------------------------------------

Yeah dont use clone is basically what they say.
                
> Exchange.copy() should make a deep copy, if the referenced objects (body, headers, properties) implements java.lang.Cloneable
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-5338
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5338
>             Project: Camel
>          Issue Type: Improvement
>    Affects Versions: 2.9.2
>            Reporter: Christian Müller
>             Fix For: 3.0.0
>
>
> We run into an issue where an exchange with a custom pojo as payload was sent to an multicast and changed in two different sub-routes at the same time (connected by using the direct protocol). The reason is that the Exchange.copy() method "only" creates shallow copies of the body (it's the same for the exchange properties and message headers). I think it's a good improvement to check whether the object implements java.lang.Cloneable and in this case create a deep copy of the object.  
> [1] https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
> [2] https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (CAMEL-5338) Exchange.copy() should make a deep copy, if the referenced objects (body, headers, properties) implements java.lang.Cloneable

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-5338?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13290026#comment-13290026 ] 

Claus Ibsen commented on CAMEL-5338:
------------------------------------

There is an onPrepare option on the EIPs such as multicast you should use for this.
http://camel.apache.org/multicast

I would suggest *not* to change anything in the current logic in the 2.x lifetime.
Also Cloneable is a bit of an anti-pattern as cloning objects in a generic way is hard.
                
> Exchange.copy() should make a deep copy, if the referenced objects (body, headers, properties) implements java.lang.Cloneable
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-5338
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5338
>             Project: Camel
>          Issue Type: Improvement
>    Affects Versions: 2.9.2
>            Reporter: Christian Müller
>             Fix For: 2.9.3, 2.10.1, 2.11
>
>
> We run into an issue where an exchange with a custom pojo as payload was sent to an multicast and changed in two different sub-routes at the same time (connected by using the direct protocol). The reason is that the Exchange.copy() method "only" creates shallow copies of the body (it's the same for the exchange properties and message headers). I think it's a good improvement to check whether the object implements java.lang.Cloneable and in this case create a deep copy of the object.  
> [1] https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
> [2] https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (CAMEL-5338) Exchange.copy() should make a deep copy, if the referenced objects (body, headers, properties) implements java.lang.Cloneable

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-5338?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13292283#comment-13292283 ] 

Claus Ibsen commented on CAMEL-5338:
------------------------------------

If you read the effective java book (by Joshua Bloch), there is an item about clone.
He basically says its broken and you should use it with care if you go down that road.

The idea in Camel 2.x was to make end users deal with this, by the onPrepare callbacks. And besides the clone, you may need to do other work as well.

What we could do in your line of idea, is to offer a pluggable SPI, where people can plugin a custom implementation that does the deep cloning. Mind that deep cloning is hard to do generic, as you would need to traverse list/maps, etc. and create new copies of them, and clone the values, and put them into the list, and so forth.

With the pluggable SPI, it can be in line with the other functionality we have for that, documented at
http://camel.apache.org/advanced-configuration-of-camelcontext-using-spring.html
                
> Exchange.copy() should make a deep copy, if the referenced objects (body, headers, properties) implements java.lang.Cloneable
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-5338
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5338
>             Project: Camel
>          Issue Type: Improvement
>    Affects Versions: 2.9.2
>            Reporter: Christian Müller
>             Fix For: 3.0.0
>
>
> We run into an issue where an exchange with a custom pojo as payload was sent to an multicast and changed in two different sub-routes at the same time (connected by using the direct protocol). The reason is that the Exchange.copy() method "only" creates shallow copies of the body (it's the same for the exchange properties and message headers). I think it's a good improvement to check whether the object implements java.lang.Cloneable and in this case create a deep copy of the object.  
> [1] https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
> [2] https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Closed] (CAMEL-5338) Exchange.copy() should make a deep copy, if the referenced objects (body, headers, properties) implements java.lang.Cloneable

Posted by "Christian Müller (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-5338?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Christian Müller closed CAMEL-5338.
-----------------------------------

    Resolution: Won't Fix
    
> Exchange.copy() should make a deep copy, if the referenced objects (body, headers, properties) implements java.lang.Cloneable
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-5338
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5338
>             Project: Camel
>          Issue Type: Improvement
>    Affects Versions: 2.9.2
>            Reporter: Christian Müller
>             Fix For: 3.0.0
>
>
> We run into an issue where an exchange with a custom pojo as payload was sent to an multicast and changed in two different sub-routes at the same time (connected by using the direct protocol). The reason is that the Exchange.copy() method "only" creates shallow copies of the body (it's the same for the exchange properties and message headers). I think it's a good improvement to check whether the object implements java.lang.Cloneable and in this case create a deep copy of the object.  
> [1] https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
> [2] https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (CAMEL-5338) Exchange.copy() should make a deep copy, if the referenced objects (body, headers, properties) implements java.lang.Cloneable

Posted by "Christian Müller (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-5338?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13402581#comment-13402581 ] 

Christian Müller commented on CAMEL-5338:
-----------------------------------------

Claus, if you agree I would close this issue.
                
> Exchange.copy() should make a deep copy, if the referenced objects (body, headers, properties) implements java.lang.Cloneable
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-5338
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5338
>             Project: Camel
>          Issue Type: Improvement
>    Affects Versions: 2.9.2
>            Reporter: Christian Müller
>             Fix For: 3.0.0
>
>
> We run into an issue where an exchange with a custom pojo as payload was sent to an multicast and changed in two different sub-routes at the same time (connected by using the direct protocol). The reason is that the Exchange.copy() method "only" creates shallow copies of the body (it's the same for the exchange properties and message headers). I think it's a good improvement to check whether the object implements java.lang.Cloneable and in this case create a deep copy of the object.  
> [1] https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
> [2] https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira