ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sevdoki...@apache.org
Subject incubator-ignite git commit: # IGNITE-777 (ConcurrentModificationException in TcpDiscoverySpi): Clone message before send to client.
Date Wed, 22 Apr 2015 10:29:48 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-777 [created] 9a14481ac


# IGNITE-777 (ConcurrentModificationException in TcpDiscoverySpi): Clone message before send
to client.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/9a14481a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/9a14481a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/9a14481a

Branch: refs/heads/ignite-777
Commit: 9a14481ac1a41cc4db96f072621152ab27167c45
Parents: 702f172
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Wed Apr 22 13:29:40 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Wed Apr 22 13:29:40 2015 +0300

----------------------------------------------------------------------
 .../spi/discovery/tcp/TcpDiscoverySpi.java      | 24 ++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9a14481a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index b40bf75..3a13b96 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -2683,8 +2683,28 @@ public class TcpDiscoverySpi extends TcpDiscoverySpiAdapter implements
TcpDiscov
             onBeforeMessageSentAcrossRing(msg);
 
             if (redirectToClients(msg)) {
-                for (ClientMessageWorker clientMsgWorker : clientMsgWorkers.values())
-                    clientMsgWorker.addMessage(msg);
+                byte[] marshalledMsg = null;
+
+                for (ClientMessageWorker clientMsgWorker : clientMsgWorkers.values()) {
+                    // Send a clone to client to avoid ConcurrentModificationException
+                    TcpDiscoveryAbstractMessage msgClone;
+
+                    try {
+                        if (marshalledMsg == null)
+                            marshalledMsg = marsh.marshal(msg);
+
+                        msgClone = marsh.unmarshal(marshalledMsg, null);
+
+                        clientMsgWorker.addMessage(msgClone);
+                    }
+                    catch (IgniteCheckedException e) {
+                        log.error("Failed to marshal message: " + msg, e);
+
+                        msgClone = msg;
+                    }
+
+                    clientMsgWorker.addMessage(msgClone);
+                }
             }
 
             Collection<TcpDiscoveryNode> failedNodes;


Mime
View raw message