From 423e469e5f73d04cf757b888dac127a7ae14b054 Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Tue, 13 Jan 2015 15:25:56 +0000 Subject: [PATCH] SOLR-6941: DistributedQueue#containsTaskWithRequestId can fail with NPE. git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1651380 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 2 ++ .../java/org/apache/solr/cloud/DistributedQueue.java | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index d21e62f3271..2bfc3e29a8c 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -435,6 +435,8 @@ Bug Fixes * SOLR-6923: AutoAddReplicas also consults live_nodes to see if a state change has happened. (Varun Thacker via Anshum Gupta) +* SOLR-6941: DistributedQueue#containsTaskWithRequestId can fail with NPE. (Mark Miller) + Optimizations ---------------------- diff --git a/solr/core/src/java/org/apache/solr/cloud/DistributedQueue.java b/solr/core/src/java/org/apache/solr/cloud/DistributedQueue.java index 1972015b3bd..99d7769bd67 100644 --- a/solr/core/src/java/org/apache/solr/cloud/DistributedQueue.java +++ b/solr/core/src/java/org/apache/solr/cloud/DistributedQueue.java @@ -122,10 +122,13 @@ public class DistributedQueue { for (String childName : childNames) { if (childName != null) { try { - ZkNodeProps message = ZkNodeProps.load(zookeeper.getData(dir + "/" + childName, null, null, true)); - if (message.containsKey(OverseerCollectionProcessor.ASYNC)) { - LOG.info(">>>> {}", message.get(OverseerCollectionProcessor.ASYNC)); - if(message.get(OverseerCollectionProcessor.ASYNC).equals(requestId)) return true; + byte[] data = zookeeper.getData(dir + "/" + childName, null, null, true); + if (data != null) { + ZkNodeProps message = ZkNodeProps.load(data); + if (message.containsKey(OverseerCollectionProcessor.ASYNC)) { + LOG.debug(">>>> {}", message.get(OverseerCollectionProcessor.ASYNC)); + if(message.get(OverseerCollectionProcessor.ASYNC).equals(requestId)) return true; + } } } catch (KeeperException.NoNodeException e) { // Another client removed the node first, try next