diff --git a/akka-cluster/src/main/scala/akka/cluster/Cluster.scala b/akka-cluster/src/main/scala/akka/cluster/Cluster.scala index 4d85d9c300..0bf7ebeba1 100644 --- a/akka-cluster/src/main/scala/akka/cluster/Cluster.scala +++ b/akka-cluster/src/main/scala/akka/cluster/Cluster.scala @@ -795,7 +795,6 @@ private[cluster] final class ClusterCore(cluster: Cluster) extends Actor with Ac latestGossip = seenVersionedGossip log.info("Cluster Node [{}] - Marked address [{}] as LEAVING", selfAddress, address) - publishState() notifyListeners(localGossip) } } @@ -819,7 +818,11 @@ private[cluster] final class ClusterCore(cluster: Cluster) extends Actor with Ac */ def removing(address: Address): Unit = { log.info("Cluster Node [{}] - Node has been REMOVED by the leader - shutting down...", selfAddress) - publishState() + val localGossip = latestGossip + // just cleaning up the gossip state + latestGossip = Gossip() + // make sure the final (removed) state is always published + notifyListeners(localGossip) cluster.shutdown() } @@ -1309,7 +1312,7 @@ private[cluster] final class ClusterCore(cluster: Cluster) extends Actor with Ac } def notifyListeners(oldGossip: Gossip): Unit = { - if (PublishStateInterval == Duration.Zero) publishState + if (PublishStateInterval == Duration.Zero) publishState() val oldMembersStatus = oldGossip.members.map(m ⇒ (m.address, m.status)) val newMembersStatus = latestGossip.members.map(m ⇒ (m.address, m.status)) diff --git a/akka-cluster/src/multi-jvm/scala/akka/cluster/NodeUpSpec.scala b/akka-cluster/src/multi-jvm/scala/akka/cluster/NodeUpSpec.scala index 3da6b2715a..f951da0801 100644 --- a/akka-cluster/src/multi-jvm/scala/akka/cluster/NodeUpSpec.scala +++ b/akka-cluster/src/multi-jvm/scala/akka/cluster/NodeUpSpec.scala @@ -38,7 +38,7 @@ abstract class NodeUpSpec "be unaffected when joining again" taggedAs LongRunningTest in { - val unexpected = new AtomicReference[SortedSet[Member]] + val unexpected = new AtomicReference[SortedSet[Member]](SortedSet.empty) cluster.registerListener(new MembershipChangeListener { def notify(members: SortedSet[Member]) { if (members.size != 2 || members.exists(_.status != MemberStatus.Up)) @@ -55,7 +55,7 @@ abstract class NodeUpSpec // let it run for a while to make sure that nothing bad happens for (n ← 1 to 20) { 100.millis.dilated.sleep() - unexpected.get must be(null) + unexpected.get must be(SortedSet.empty) cluster.latestGossip.members.forall(_.status == MemberStatus.Up) must be(true) }