Mads Bondo Dydensborg created SOLR-14700:
--------------------------------------------

             Summary: CloudSolrClient cannot be used without setting an 
explicit streamContext
                 Key: SOLR-14700
                 URL: https://issues.apache.org/jira/browse/SOLR-14700
             Project: Solr
          Issue Type: Bug
      Security Level: Public (Default Security Level. Issues are Public)
          Components: clients - java
    Affects Versions: 8.6
            Reporter: Mads Bondo Dydensborg


A naive approach to using CloudSolrClient, such as on this page: 
[http://joelsolr.blogspot.com/2015/04/the-streaming-api-solrjio-basics.html] - 
will not work: opening the stream will throw an IOException with an embedded 
NullPointerException.

This took me a while to figure out, and I think it would be good to either 
update the documentation or "fix" the constructor to set the needed 
streamContext as appropriate.

I found this snippet of code in TuppleStream.java, that seems to "almost" work 
without a streamContext:


{code:java}
// line 127 in the sources to TuppleStream.java:
public static List<String> getShards(String zkHost,
                                       String collection,
                                       StreamContext streamContext,
                                       SolrParams requestParams)
...

// line 135
if(streamContext != null) {
      shardsMap = (Map<String, List<String>>)streamContext.get("shards");
    }
...
// line 144
CloudSolrClient cloudSolrClient =
          
Optional.ofNullable(streamContext.getSolrClientCache()).orElseGet(SolrClientCache::new).getCloudSolrClient(zkHost);

{code}
if streamContext is null in the last statement, a NullPointerException will be 
thrown and open'ening the stream will fail.

This took me way too long time to figure out.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

Reply via email to