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/29 12:35:23 UTC
[lucene-solr] branch reference_impl updated: @623 Fix double close
and NPE that can be hit.
This is an automated email from the ASF dual-hosted git repository.
markrmiller pushed a commit to branch reference_impl
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/reference_impl by this push:
new 47412d8 @623 Fix double close and NPE that can be hit.
47412d8 is described below
commit 47412d82c362ba8c53691e1b8616d0b6422340ad
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Sat Aug 29 07:34:43 2020 -0500
@623 Fix double close and NPE that can be hit.
---
.../apache/solr/client/solrj/io/stream/SolrStream.java | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/SolrStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/SolrStream.java
index e879325..e17a768 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/SolrStream.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/SolrStream.java
@@ -19,6 +19,7 @@ package org.apache.solr.client.solrj.io.stream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -62,8 +63,8 @@ public class SolrStream extends TupleStream {
private boolean trace;
private Map<String, String> fieldMappings;
private transient TupleStreamParser tupleStreamParser;
- private transient Http2SolrClient client;
- private transient SolrClientCache cache;
+ private transient volatile Http2SolrClient client;
+ private transient volatile SolrClientCache cache;
private String slice;
private long checkpoint = -1;
private CloseableHttpResponse closeableHttpResponse;
@@ -86,7 +87,7 @@ public class SolrStream extends TupleStream {
}
public List<TupleStream> children() {
- return new ArrayList();
+ return Collections.emptyList();
}
public String getBaseUrl() {
@@ -110,8 +111,12 @@ public class SolrStream extends TupleStream {
**/
public void open() throws IOException {
- if(cache == null) {
- client = new Http2SolrClient.Builder(baseUrl).markInternalRequest().build();
+ if (cache == null) {
+ synchronized (this) {
+ if (cache == null) {
+ client = new Http2SolrClient.Builder(baseUrl).markInternalRequest().build();
+ }
+ }
} else {
client = cache.getHttpSolrClient(baseUrl);
}
@@ -190,7 +195,6 @@ public class SolrStream extends TupleStream {
closeableHttpResponse.close();
}
IOUtils.closeQuietly(tupleStreamParser);
- tupleStreamParser.close();
// if the cache is null, then we opened the client
if (cache == null && client != null) {