SOLR-377: make sure FastWriter buffer is flushed after writing response

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@586617 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2007-10-19 21:26:05 +00:00
parent 37345a65d3
commit a899f9e24b
6 changed files with 30 additions and 6 deletions

View File

@ -43,7 +43,11 @@ public class JSONResponseWriter implements QueryResponseWriter {
public void write(Writer writer, SolrQueryRequest req, SolrQueryResponse rsp) throws IOException {
JSONWriter w = new JSONWriter(writer, req, rsp);
w.writeResponse();
try {
w.writeResponse();
} finally {
w.close();
}
}
public String getContentType(SolrQueryRequest request, SolrQueryResponse response) {
@ -83,7 +87,6 @@ class JSONWriter extends TextResponseWriter {
if(wrapperFunction!=null) {
writer.write(')');
}
writer.flushBuffer();
}
protected void writeKey(String fname, boolean needsEscaping) throws IOException {

View File

@ -31,7 +31,11 @@ public class PHPResponseWriter implements QueryResponseWriter {
public void write(Writer writer, SolrQueryRequest req, SolrQueryResponse rsp) throws IOException {
PHPWriter w = new PHPWriter(writer, req, rsp);
w.writeResponse();
try {
w.writeResponse();
} finally {
w.close();
}
}
public String getContentType(SolrQueryRequest request, SolrQueryResponse response) {

View File

@ -43,7 +43,11 @@ public class PHPSerializedResponseWriter implements QueryResponseWriter {
public void write(Writer writer, SolrQueryRequest req, SolrQueryResponse rsp) throws IOException {
PHPSerializedWriter w = new PHPSerializedWriter(writer, req, rsp);
w.writeResponse();
try {
w.writeResponse();
} finally {
w.close();
}
}
public String getContentType(SolrQueryRequest request, SolrQueryResponse response) {

View File

@ -31,7 +31,11 @@ public class PythonResponseWriter implements QueryResponseWriter {
public void write(Writer writer, SolrQueryRequest req, SolrQueryResponse rsp) throws IOException {
PythonWriter w = new PythonWriter(writer, req, rsp);
w.writeResponse();
try {
w.writeResponse();
} finally {
w.close();
}
}
public String getContentType(SolrQueryRequest request, SolrQueryResponse response) {

View File

@ -30,7 +30,11 @@ public class RubyResponseWriter implements QueryResponseWriter {
public void write(Writer writer, SolrQueryRequest req, SolrQueryResponse rsp) throws IOException {
RubyWriter w = new RubyWriter(writer, req, rsp);
w.writeResponse();
try {
w.writeResponse();
} finally {
w.close();
}
}
public String getContentType(SolrQueryRequest request, SolrQueryResponse response) {

View File

@ -59,6 +59,11 @@ public abstract class TextResponseWriter {
returnFields = rsp.getReturnFields();
}
/** done with this ResponseWriter... make sure any buffers are flushed to writer */
public void close() throws IOException {
writer.flushBuffer();
}
/** returns the Writer that the response is being written to */
public Writer getWriter() { return writer; }