cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmcken...@apache.org
Subject [11/14] cassandra git commit: Fix potential NPE while assasinating unknown endpoint
Date Wed, 02 Dec 2015 16:14:27 GMT
Fix potential NPE while assasinating unknown endpoint

Patch by dbrosius; reviewed by jknighton for CASSANDRA-9510


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

Branch: refs/heads/trunk
Commit: b89037fe400b2b5097961c8276fa5c157b6cd49c
Parents: 4743fd7
Author: Dave Brosius <dbrosius@mebigfatguy.com>
Authored: Wed Dec 2 11:06:40 2015 -0500
Committer: Joshua McKenzie <jmckenzie@apache.org>
Committed: Wed Dec 2 11:06:40 2015 -0500

----------------------------------------------------------------------
 src/java/org/apache/cassandra/gms/Gossiper.java | 23 ++++++++++----------
 1 file changed, 12 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b89037fe/src/java/org/apache/cassandra/gms/Gossiper.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/gms/Gossiper.java b/src/java/org/apache/cassandra/gms/Gossiper.java
index 83ae92d..43a45cf 100644
--- a/src/java/org/apache/cassandra/gms/Gossiper.java
+++ b/src/java/org/apache/cassandra/gms/Gossiper.java
@@ -580,17 +580,6 @@ public class Gossiper implements IFailureDetectionEventListener, GossiperMBean
         }
         else
         {
-            try
-            {
-                tokens = StorageService.instance.getTokenMetadata().getTokens(endpoint);
-            }
-            catch (Throwable th)
-            {
-                JVMStabilityInspector.inspectThrowable(th);
-                // TODO this is broken
-                logger.warn("Unable to calculate tokens for {}.  Will use a random one",
address);
-                tokens = Collections.singletonList(StorageService.instance.getTokenMetadata().partitioner.getRandomToken());
-            }
             int generation = epState.getHeartBeatState().getGeneration();
             int heartbeat = epState.getHeartBeatState().getHeartBeatVersion();
             logger.info("Sleeping for {}ms to ensure {} does not change", StorageService.RING_DELAY,
endpoint);
@@ -607,6 +596,18 @@ public class Gossiper implements IFailureDetectionEventListener, GossiperMBean
             epState.getHeartBeatState().forceNewerGenerationUnsafe();
         }
 
+        try
+        {
+            tokens = StorageService.instance.getTokenMetadata().getTokens(endpoint);
+        }
+        catch (Throwable th)
+        {
+            JVMStabilityInspector.inspectThrowable(th);
+            // TODO this is broken
+            logger.warn("Unable to calculate tokens for {}.  Will use a random one", address);
+            tokens = Collections.singletonList(StorageService.instance.getTokenMetadata().partitioner.getRandomToken());
+        }
+
         // do not pass go, do not collect 200 dollars, just gtfo
         epState.addApplicationState(ApplicationState.STATUS, StorageService.instance.valueFactory.left(tokens,
computeExpireTime()));
         handleMajorStateChange(endpoint, epState);


Mime
View raw message