You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ch...@apache.org on 2012/02/14 12:05:59 UTC
svn commit: r1243874 - in /lucene/dev/branches/branch_3x/solr: CHANGES.txt
core/src/java/org/apache/solr/core/SolrCore.java
core/src/java/org/apache/solr/response/JSONResponseWriter.java
Author: chrism
Date: Tue Feb 14 11:05:58 2012
New Revision: 1243874
URL: http://svn.apache.org/viewvc?rev=1243874&view=rev
Log:
SOLR-3005: Fixed JSONResponseWriter content type disappearing when only default writers used
Modified:
lucene/dev/branches/branch_3x/solr/CHANGES.txt
lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/SolrCore.java
lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/response/JSONResponseWriter.java
Modified: lucene/dev/branches/branch_3x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/CHANGES.txt?rev=1243874&r1=1243873&r2=1243874&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_3x/solr/CHANGES.txt Tue Feb 14 11:05:58 2012
@@ -218,6 +218,9 @@ Other Changes
* SOLR-3097, SOLR-3105: Add analysis configurations for different languages to
the example. (Christian Moen, Robert Muir)
+* SOLR-3005: Default QueryResponseWriters are now initialized via init() with an empty
+ NamedList. (Gasol Wu, Chris Male)
+
Build
----------------------
* SOLR-2487: Add build target to package war without slf4j jars (janhoy)
Modified: lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/SolrCore.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/SolrCore.java?rev=1243874&r1=1243873&r2=1243874&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/SolrCore.java (original)
+++ lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/SolrCore.java Tue Feb 14 11:05:58 2012
@@ -1515,8 +1515,13 @@ public final class SolrCore implements S
}
}
+ NamedList emptyList = new NamedList();
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
Modified: lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/response/JSONResponseWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/response/JSONResponseWriter.java?rev=1243874&r1=1243873&r2=1243874&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/response/JSONResponseWriter.java (original)
+++ lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/response/JSONResponseWriter.java Tue Feb 14 11:05:58 2012
@@ -41,13 +41,15 @@ import java.util.*;
*/
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) {
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 {