Don't check for expireTime if node is not in REMOVED Patch by thobbs, reviewed by brandonwilliams for CASSANDRA-6564
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/c612a364 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/c612a364 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/c612a364 Branch: refs/heads/cassandra-2.0 Commit: c612a364951c02d95ead41fb54048fa8fcb35265 Parents: 9771cea Author: Brandon Williams <brandonwilli...@apache.org> Authored: Fri Jan 24 12:49:19 2014 -0600 Committer: Brandon Williams <brandonwilli...@apache.org> Committed: Fri Jan 24 12:49:19 2014 -0600 ---------------------------------------------------------------------- .../org/apache/cassandra/service/StorageService.java | 3 ++- .../cassandra/service/LeaveAndBootstrapTest.java | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/c612a364/src/java/org/apache/cassandra/service/StorageService.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java index 8491cb0..ab266d8 100644 --- a/src/java/org/apache/cassandra/service/StorageService.java +++ b/src/java/org/apache/cassandra/service/StorageService.java @@ -1716,7 +1716,8 @@ public class StorageService extends NotificationBroadcasterSupport implements IE } else // now that the gossiper has told us about this nonexistent member, notify the gossiper to remove it { - addExpireTimeIfFound(endpoint, extractExpireTime(pieces, MessagingService.instance().getVersion(endpoint))); + if (VersionedValue.REMOVED_TOKEN.equals(pieces[0])) + addExpireTimeIfFound(endpoint, extractExpireTime(pieces, MessagingService.instance().getVersion(endpoint))); removeEndpoint(endpoint); } } http://git-wip-us.apache.org/repos/asf/cassandra/blob/c612a364/test/unit/org/apache/cassandra/service/LeaveAndBootstrapTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/service/LeaveAndBootstrapTest.java b/test/unit/org/apache/cassandra/service/LeaveAndBootstrapTest.java index 658a4a9..de7958f 100644 --- a/test/unit/org/apache/cassandra/service/LeaveAndBootstrapTest.java +++ b/test/unit/org/apache/cassandra/service/LeaveAndBootstrapTest.java @@ -681,6 +681,19 @@ public class LeaveAndBootstrapTest assertEquals("rack42", SystemTable.loadDcRackInfo().get(toRemove).get("rack")); } + @Test + public void testRemovingStatusForNonMember() throws UnknownHostException + { + // create a ring of 1 node + StorageService ss = StorageService.instance; + VersionedValue.VersionedValueFactory valueFactory = new VersionedValue.VersionedValueFactory(partitioner); + Util.createInitialRing(ss, partitioner, new ArrayList<Token>(), new ArrayList<Token>(), new ArrayList<InetAddress>(), new ArrayList<UUID>(), 1); + + // make a REMOVING state change on a non-member endpoint; without the CASSANDRA-6564 fix, this + // would result in an ArrayIndexOutOfBoundsException + ss.onChange(InetAddress.getByName("192.168.1.42"), ApplicationState.STATUS, valueFactory.removingNonlocal(UUID.randomUUID())); + } + private static Collection<InetAddress> makeAddrs(String... hosts) throws UnknownHostException { ArrayList<InetAddress> addrs = new ArrayList<InetAddress>(hosts.length);