mirror of https://github.com/apache/lucene.git
SOLR-3005: Fixed JSONResponseWriter content type disappearing when only default writers used
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1243870 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d537ecf07f
commit
e36f317d7b
|
@ -420,6 +420,9 @@ Other Changes
|
||||||
* SOLR-2105: Remove support for deprecated "update.processor" (since 3.2), in favor of
|
* SOLR-2105: Remove support for deprecated "update.processor" (since 3.2), in favor of
|
||||||
"update.chain" (janhoy)
|
"update.chain" (janhoy)
|
||||||
|
|
||||||
|
* SOLR-3005: Default QueryResponseWriters are now initialized via init() with an empty
|
||||||
|
NamedList. (Gasol Wu, Chris Male)
|
||||||
|
|
||||||
|
|
||||||
Documentation
|
Documentation
|
||||||
----------------------
|
----------------------
|
||||||
|
|
|
@ -1650,8 +1650,13 @@ public final class SolrCore implements SolrInfoMBean {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NamedList emptyList = new NamedList();
|
||||||
for (Map.Entry<String, QueryResponseWriter> entry : DEFAULT_RESPONSE_WRITERS.entrySet()) {
|
for (Map.Entry<String, QueryResponseWriter> entry : DEFAULT_RESPONSE_WRITERS.entrySet()) {
|
||||||
if(responseWriters.get(entry.getKey()) == null) responseWriters.put(entry.getKey(), entry.getValue());
|
if(responseWriters.get(entry.getKey()) == null) {
|
||||||
|
responseWriters.put(entry.getKey(), entry.getValue());
|
||||||
|
// call init so any logic in the default writers gets invoked
|
||||||
|
entry.getValue().init(emptyList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// configure the default response writer; this one should never be null
|
// configure the default response writer; this one should never be null
|
||||||
|
|
|
@ -40,13 +40,15 @@ import org.apache.solr.search.ReturnFields;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class JSONResponseWriter implements QueryResponseWriter {
|
public class JSONResponseWriter implements QueryResponseWriter {
|
||||||
static String CONTENT_TYPE_JSON_UTF8="application/json; charset=UTF-8";
|
static String CONTENT_TYPE_JSON_UTF8 = "application/json; charset=UTF-8";
|
||||||
|
|
||||||
private String contentType;
|
private String contentType = CONTENT_TYPE_JSON_UTF8;
|
||||||
|
|
||||||
public void init(NamedList namedList) {
|
public void init(NamedList namedList) {
|
||||||
String contentType = (String) namedList.get("content-type");
|
String contentType = (String) namedList.get("content-type");
|
||||||
this.contentType = (contentType != null) ? contentType : CONTENT_TYPE_JSON_UTF8;
|
if (contentType != null) {
|
||||||
|
this.contentType = contentType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(Writer writer, SolrQueryRequest req, SolrQueryResponse rsp) throws IOException {
|
public void write(Writer writer, SolrQueryRequest req, SolrQueryResponse rsp) throws IOException {
|
||||||
|
|
Loading…
Reference in New Issue