Treat MemberStatus.Removed as terminal state in ClusterReadView (#25499)

* Fixes #25489 where cluster event for a previous state can override
the call to cluster.close settings it to remove
* Fix case where Removed is used as a placeholder for unknown
This commit is contained in:
Christopher Batey 2018-10-03 13:01:38 +01:00 committed by Johan Andrén
parent 1d65159923
commit ba67f71ca8

View file

@ -35,6 +35,9 @@ private[akka] class ClusterReadView(cluster: Cluster) extends Closeable {
@volatile
private var _cachedSelf: OptionVal[Member] = OptionVal.None
@volatile
private var _closed: Boolean = false
/**
* Current internal cluster stats, updated periodically via event bus.
*/
@ -87,7 +90,12 @@ private[akka] class ClusterReadView(cluster: Cluster) extends Closeable {
e match {
case e: MemberEvent if e.member.address == selfAddress
_cachedSelf match {
case OptionVal.Some(s) if s.status == MemberStatus.Removed && _closed
// ignore as Cluster.close has been called
case _
_cachedSelf = OptionVal.Some(e.member)
}
case _
}
case s: CurrentClusterState _state = s
@ -186,6 +194,7 @@ private[akka] class ClusterReadView(cluster: Cluster) extends Closeable {
* Unsubscribe to cluster events.
*/
def close(): Unit = {
_closed = true
_cachedSelf = OptionVal.Some(self.copy(MemberStatus.Removed))
if (!eventBusListener.isTerminated)
eventBusListener ! PoisonPill