NPE in RaftActor#onGetOnDemandRaftStats 54/18854/4
authorTom Pantelis <tpanteli@brocade.com>
Wed, 22 Apr 2015 06:09:15 +0000 (02:09 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Thu, 23 Apr 2015 11:22:59 +0000 (07:22 -0400)
I had a 3 node setup with 1 node down and when I tried to access the
shard info via JConsole I saw this exception :

java.lang.NullPointerException: null value in entry:
member-3-shard-car-config=null
        at
com.google.common.collect.CollectPreconditions.checkEntryNotNull(CollectPreconditions.java:33)[114:com.google.guava:18.0.0]
        at
com.google.common.collect.RegularImmutableMap.<init>(RegularImmutableMap.java:88)[114:com.google.guava:18.0.0]
        at
com.google.common.collect.ImmutableMap.copyOf(ImmutableMap.java:294)[114:com.google.guava:18.0.0]
        at
org.opendaylight.controller.cluster.raft.RaftActor.onGetOnDemandRaftStats(RaftActor.java:247)[227:org.opendaylight.controller.sal-akka-raft:1.2.0.SNAPSHOT]

The peer address in the map for the down node was null which
ImmutableMap.copyOf doesn't like. I changed it to HashMap.

Change-Id: If9e0dfb3f7f213c11c99d98a5fd9c804c0876776
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java

index 4485f3b14457c5f61fe614eaaec226218d0ab3a4..1738cc5fe001ab8b30cfd105f67dc4d9adcc8200 100644 (file)
@@ -16,10 +16,10 @@ import akka.persistence.SnapshotSelectionCriteria;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Objects;
 import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
 import java.io.Serializable;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
@@ -259,7 +259,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor {
                 .snapshotIndex(replicatedLog().getSnapshotIndex())
                 .snapshotTerm(replicatedLog().getSnapshotTerm())
                 .votedFor(context.getTermInformation().getVotedFor())
-                .peerAddresses(ImmutableMap.copyOf(context.getPeerAddresses()));
+                .peerAddresses(new HashMap<>(context.getPeerAddresses()));
 
         ReplicatedLogEntry lastLogEntry = getLastLogEntry();
         if (lastLogEntry != null) {