You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/08/20 15:43:17 UTC

[lucene-solr] branch reference_impl_dev updated: @581 Fix NPE race.

This is an automated email from the ASF dual-hosted git repository.

markrmiller pushed a commit to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/reference_impl_dev by this push:
     new f33cc38  @581 Fix NPE race.
f33cc38 is described below

commit f33cc3870127a7425a89aca12fd23cf5322d8072
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Thu Aug 20 10:42:42 2020 -0500

    @581 Fix NPE race.
---
 .../java/org/apache/solr/common/cloud/ZkStateReader.java   | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
index 8002af9..4e2cd2c 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
@@ -718,8 +718,8 @@ public class ZkStateReader implements SolrCloseable {
     public DocCollection get(boolean allowCached) {
       gets.incrementAndGet();
       if (!allowCached || lastUpdateTime < 0 || System.nanoTime() - lastUpdateTime > LAZY_CACHE_TIME) {
-        boolean shouldFetch = true;
-        if (cachedDocCollection != null) {
+        DocCollection fcachedDocCollection = cachedDocCollection;
+        if (fcachedDocCollection != null) {
           Stat exists = null;
           try {
             exists = zkClient.exists(getCollectionPath(collName), null);
@@ -727,14 +727,12 @@ public class ZkStateReader implements SolrCloseable {
             ParWork.propegateInterrupt(e);
             throw new SolrException(ErrorCode.SERVER_ERROR, e);
           }
-          if (exists != null && exists.getVersion() == cachedDocCollection.getZNodeVersion()) {
-            shouldFetch = false;
+          if (exists != null && exists.getVersion() == fcachedDocCollection.getZNodeVersion()) {
+            return fcachedDocCollection;
           }
         }
-        if (shouldFetch) {
-          cachedDocCollection = getCollectionLive(ZkStateReader.this, collName);
-          lastUpdateTime = System.nanoTime();
-        }
+        cachedDocCollection = getCollectionLive(ZkStateReader.this, collName);
+        lastUpdateTime = System.nanoTime();
       }
       return cachedDocCollection;
     }