fix NPE in comparator
This commit is contained in:
+1
-1
@@ -264,7 +264,7 @@ public class ShardDiscoveryService implements com.inteligr8.alfresco.asie.spi.Sh
|
||||
ShardInstanceState nodeShardState = ShardInstanceState.from(shardState);
|
||||
|
||||
Pair<SolrHost, ShardInstanceState> pair = new Pair<>(node, nodeShardState);
|
||||
if (comparator.compare(pair, shardNodeStates.get(shardId)) < 0)
|
||||
if (!shardNodeStates.containsKey(shardId) || comparator.compare(pair, shardNodeStates.get(shardId)) < 0)
|
||||
shardNodeStates.put(shardId, pair);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +125,9 @@ public interface ShardDiscoveryService {
|
||||
public class ShardedNodeShardStateComparator implements Comparator<Pair<SolrHost, ShardInstanceState>> {
|
||||
@Override
|
||||
public int compare(Pair<SolrHost, ShardInstanceState> p1, Pair<SolrHost, ShardInstanceState> p2) {
|
||||
return - Long.compare(p1.getSecond().getLastIndexedTxId(), p2.getSecond().getLastIndexedTxId());
|
||||
if (p1 == null) return 1;
|
||||
else if (p2 == null) return -1;
|
||||
else return - Long.compare(p1.getSecond().getLastIndexedTxId(), p2.getSecond().getLastIndexedTxId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user