[
https://issues.apache.org/jira/browse/SOLR-5532?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13840396#comment-13840396
]
Hoss Man commented on SOLR-5532:
--------------------------------
The specific error message being returned here by HttpSolrServer is from lines
438-456 _(*NOT* 140 as initially mentioned in the bug report)_ ...
{code}
String procCt = processor.getContentType();
if (procCt != null) {
if (!contentType.equals(procCt)) {
// unexpected content type
String msg = "Expected content type " + procCt + " but got " +
contentType + ".";
Header encodingHeader = response.getEntity().getContentEncoding();
String encoding;
if (encodingHeader != null) {
encoding = encodingHeader.getValue();
} else {
encoding = "UTF-8"; // try UTF-8
}
try {
msg = msg + " " + IOUtils.toString(respBody, encoding);
} catch (IOException e) {
throw new RemoteSolrException(httpStatus, "Could not parse response
with encoding " + encoding, e);
}
RemoteSolrException e = new RemoteSolrException(httpStatus, msg,
null);
throw e;
}
}
{code}
...the intent of this code is to ensure that the Content-Type of the response
it has received from the server is something that the ResponseParser it's
configured to use is capable of handling.
The code as written definitely seems sketchy, because it's trying to do an
exact string equality match on the Content-Type, even though (as in this
example)...
{{application/xml; charset=UTF-8}} (with space)
...should be considered equivalent to...
{{application/xml;charset=UTF-8}} (no space)
... nothing in the spec requries whitespcae there, or makes them semantically
un-equivilent.
having said that however: i'm still not clear on how to actually reproduce this.
As far as i can tell from a quick check, the XML response writer (on the
server) has always included a space in it's Content-Type, and that doesn't seem
to have changed in 4.6, and the solrj expected XML Content-Type (on the client
parser) has always expected a space in the Content-Type, and that doesn't seem
to have changed in 4.6.
Can you pleas show us..
* the full source code of a test client that demonstrates this problem for you?
* the full stack trace produced by your test code
* the command line used to run your test case (with full classpath showing jar
versions used)
* the response you get from "curl -v http://localhost:8983/solr/admin/system"
* the response you get from "curl -v
http://localhost:8983/solr/collection1/admin/ping"
bq. A global search for "charset=UTF-8" on the source code of solrj indicates
that other functions besides "ping" might be affected as well, because there
are several places where "application/xml; charset=UTF-8" is spelled without a
space after the semicolon.
Can you please be specific? I just did the same search of the 4.6 codebase and
i can't find anything like what you are describing.
> HttpSolrServer does not accept content type of "ping" response
> --------------------------------------------------------------
>
> Key: SOLR-5532
> URL: https://issues.apache.org/jira/browse/SOLR-5532
> Project: Solr
> Issue Type: New Feature
> Affects Versions: 4.6
> Environment: Windows 7, Java 1.7.0_45 (64bit), solr-solrj-4.6.0.jar
> Reporter: Jakob Furrer
>
> I just upgraded my Solr instance and with it I also upgraded the solrj
> library in our custom application which sends diverse requests and queries to
> Solr.
> I use the "ping" method to determine whether Solr started correctly under the
> configured address. Since the upgrade the ping response results in an error:
> {code:xml}
> Cause: org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException:
> Expected content type application/xml; charset=UTF-8 but got
> application/xml;charset=UTF-8.
> <?xml version="1.0" encoding="UTF-8"?>
> <response>
> <lst name="responseHeader"><int name="status">0</int><int
> name="QTime">0</int><lst name="params"><str name="df">searchtext</str><str
> name="echoParams">all</str><str name="rows">10</str><str
> name="echoParams">all</str><str name="wt">xml</str><str
> name="version">2.2</str><str name="q">solrpingquery</str><str
> name="distrib">false</str></lst></lst><str name="status">OK</str>
> </response>
> {code}
> The Solr application itself works fine.
> Using an older version of the solrj library than solr-solrj-4.6.0.jar (e.g.
> solr-solrj-4.5.1.jar) in the custom application does not produce this error.
> The Exception is produced in a Code block (_HttpSolrServer.java_, method
> _request(...)_, around. line 140) which has been introduced with version
> 4.6.0.
> Code to reproduce the error:
> {code:xml}
> try {
> HttpSolrServer solrServer = new
> HttpSolrServer("my-solr-application-address");
> solrServer.ping();
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> {code}
> A global search for "charset=UTF-8" on the source code of solrj indicates
> that other functions besides "ping" might be affected as well, because there
> are several places where "application/xml; charset=UTF-8" is spelled without
> a space after the semicolon.
--
This message was sent by Atlassian JIRA
(v6.1#6144)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]