madrob commented on a change in pull request #1754:
URL: https://github.com/apache/lucene-solr/pull/1754#discussion_r471546425



##########
File path: 
solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/TupleStream.java
##########
@@ -141,19 +141,30 @@ public UUID getStreamNodeId(){
       shards = shardsMap.get(collection);
     } else {
       //SolrCloud Sharding
-      CloudSolrClient cloudSolrClient =
-          
Optional.ofNullable(streamContext.getSolrClientCache()).orElseGet(SolrClientCache::new).getCloudSolrClient(zkHost);
+      SolrClientCache solrClientCache = (streamContext != null ? 
streamContext.getSolrClientCache() : null);
+      final SolrClientCache localSolrClientCache;
+      if (solrClientCache == null) {
+        solrClientCache = localSolrClientCache = new SolrClientCache();
+      } else {
+        localSolrClientCache = null;
+      }
+      CloudSolrClient cloudSolrClient = 
solrClientCache.getCloudSolrClient(zkHost);
       ZkStateReader zkStateReader = cloudSolrClient.getZkStateReader();
       ClusterState clusterState = zkStateReader.getClusterState();
       Slice[] slices = CloudSolrStream.getSlices(collection, zkStateReader, 
true);
       Set<String> liveNodes = clusterState.getLiveNodes();
 
 
-      ModifiableSolrParams solrParams = new 
ModifiableSolrParams(streamContext.getRequestParams());
+      final ModifiableSolrParams solrParams;
+      if (streamContext != null) {
+        solrParams = new 
ModifiableSolrParams(streamContext.getRequestParams());
+      } else {
+        solrParams = new ModifiableSolrParams();
+      }
       solrParams.add(requestParams);
 
       RequestReplicaListTransformerGenerator 
requestReplicaListTransformerGenerator =
-          
Optional.ofNullable(streamContext.getRequestReplicaListTransformerGenerator()).orElseGet(RequestReplicaListTransformerGenerator::new);
+          Optional.ofNullable(streamContext != null ? 
streamContext.getRequestReplicaListTransformerGenerator() : 
null).orElseGet(RequestReplicaListTransformerGenerator::new);

Review comment:
       Yea, I think an extra null check is going to be more clear than the use 
of Optional here.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to