Skip to content

Commit

Permalink
APPNG-2484
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias committed Sep 6, 2023
1 parent 39101d3 commit 5260e66
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@
import lombok.extern.slf4j.Slf4j;

/**
* Utility class to retrieve the {@link HazelcastInstance} to be used by appNG.
* This instance is then being used by {@link CacheService} and also by
* {@link HazelcastReceiver}.
* Utility class to retrieve the {@link HazelcastInstance} to be used by appNG. This instance is then being used by
* {@link CacheService} and also by {@link HazelcastReceiver}.
*
* @author Matthias Müller
*/
Expand Down Expand Up @@ -121,7 +120,8 @@ private static MembershipListener getMembershipListener(Environment environment)

return new MembershipListener() {

final ScopedEnvironment scoped = ((DefaultEnvironment) environment).getEnvironment(Scope.PLATFORM);
final ScopedEnvironment scoped = null == environment ? null
: ((DefaultEnvironment) environment).getEnvironment(Scope.PLATFORM);

@Override
public void memberRemoved(MembershipEvent me) {
Expand All @@ -130,12 +130,14 @@ public void memberRemoved(MembershipEvent me) {
InetSocketAddress socketAddress = member.getSocketAddress();
String nodeId = socketAddress.getHostName();
LOGGER.info("Node removed: {} ({})", address, nodeId);
Map<String, NodeState> clusterState = scoped.getAttribute(NodeEvent.NODE_STATE);
NodeState removed = clusterState.remove(nodeId);
if (removed == null) {
LOGGER.warn("Failed removing node '{}' from cluster state.", nodeId);
} else {
LOGGER.info("Removed node '{}' from cluster state.", nodeId);
if (null != scoped) {
Map<String, NodeState> clusterState = scoped.getAttribute(NodeEvent.NODE_STATE);
NodeState removed = clusterState.remove(nodeId);
if (removed == null) {
LOGGER.warn("Failed removing node '{}' from cluster state.", nodeId);
} else {
LOGGER.info("Removed node '{}' from cluster state.", nodeId);
}
}
}

Expand Down

0 comments on commit 5260e66

Please sign in to comment.