Shalin Shekhar Mangar created SOLR-8366:
-------------------------------------------

             Summary: ConcurrentUpdateSolrClient attempts to use response's 
content type as charset encoding
                 Key: SOLR-8366
                 URL: https://issues.apache.org/jira/browse/SOLR-8366
             Project: Solr
          Issue Type: Bug
          Components: clients - java
    Affects Versions: 5.3, 5.4
            Reporter: Shalin Shekhar Mangar
            Priority: Minor
             Fix For: Trunk, 5.5


While debugging the SolrExampleStreamingTest.testUpdateField failures on trunk, 
I noticed that ConcurrentUpdateSolrClient always logs the following when the 
server throws a conflict error:
{code}
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
{code}

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.
{code}
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);
            }
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to