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

ConcurrentUpdateSolrClient attempts to use response's content type as charset encoding for parsing exceptions

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 5.3, 5.4
    • 5.5, 6.0
    • clients - java
    • None

    Description

      While debugging the SolrExampleStreamingTest.testUpdateField failures on trunk, I noticed that ConcurrentUpdateSolrClient always logs the following when the server throws a conflict error:

      WARN  (concurrentUpdateScheduler-2-thread-1-processing-http:////127.0.0.1:35848//solr//collection1) [    ] o.a.s.c.s.i.ConcurrentUpdateSolrClient Failed to parse error response from http://127.0.0.1:35848/solr/collection1 due to: org.apache.solr.common.SolrException: parsing error
      

      The problem is the following code which uses the response.getEntity().getContentType().getValue() as the charset encoding which is wrong because content type has mime type as well as charset.

      try {
                    NamedList<Object> resp =
                        client.parser.processResponse(response.getEntity().getContent(),
                            response.getEntity().getContentType().getValue());
                    NamedList<Object> error = (NamedList<Object>) resp.get("error");
                    if (error != null)
                      solrExc.setMetadata((NamedList<String>) error.get("metadata"));
                  } catch (Exception exc) {
                    // don't want to fail to report error if parsing the response fails
                    log.warn("Failed to parse error response from " + client.getBaseURL() + " due to: " + exc);
                  }
      

      Attachments

        1. SOLR-8336.patch
          2 kB
          Shalin Shekhar Mangar

        Activity

          People

            shalin Shalin Shekhar Mangar
            shalin Shalin Shekhar Mangar
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: