Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-14700

CloudSolrClient cannot be used without setting an explicit streamContext

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 8.6
    • 8.7, 9.0
    • clients - java
    • None

    Description

      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:

      // 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);
      
      

      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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mabd Mads Bondo Dydensborg
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 10m
                  1h 10m