cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [4/6] git commit: Fix potential ConcurrentModificationException in tests
Date Tue, 19 Nov 2013 17:27:33 GMT
Fix potential ConcurrentModificationException in tests


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/39e3a5e0
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/39e3a5e0
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/39e3a5e0

Branch: refs/heads/trunk
Commit: 39e3a5e039a61e649827950bb36f67617e0bd884
Parents: eeb8d1b
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Tue Nov 19 18:13:23 2013 +0100
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Tue Nov 19 18:23:02 2013 +0100

----------------------------------------------------------------------
 .../apache/cassandra/locator/TokenMetadata.java | 22 +++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/39e3a5e0/src/java/org/apache/cassandra/locator/TokenMetadata.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/locator/TokenMetadata.java b/src/java/org/apache/cassandra/locator/TokenMetadata.java
index ac9a1d0..5ab1b3f 100644
--- a/src/java/org/apache/cassandra/locator/TokenMetadata.java
+++ b/src/java/org/apache/cassandra/locator/TokenMetadata.java
@@ -876,13 +876,21 @@ public class TokenMetadata
     /** used by tests */
     public void clearUnsafe()
     {
-        bootstrapTokens.clear();
-        tokenToEndpointMap.clear();
-        topology.clear();
-        leavingEndpoints.clear();
-        pendingRanges.clear();
-        endpointToHostIdMap.clear();
-        invalidateCaches();
+        lock.writeLock().lock();
+        try
+        {
+            bootstrapTokens.clear();
+            tokenToEndpointMap.clear();
+            topology.clear();
+            leavingEndpoints.clear();
+            pendingRanges.clear();
+            endpointToHostIdMap.clear();
+            invalidateCaches();
+        }
+        finally
+        {
+            lock.writeLock().unlock();
+        }
     }
 
     public String toString()


Mime
View raw message