SOLR-973 followup -- Lookup the charset only once

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@756879 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2009-03-21 06:02:43 +00:00
parent cc963a1aea
commit 08fb323869
1 changed files with 3 additions and 1 deletions

View File

@ -26,6 +26,7 @@ import java.io.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.nio.charset.Charset;
/**
* A RequestWriter is used to write requests to Solr.
@ -36,6 +37,7 @@ import java.util.List;
* @since solr 1.4
*/
public class RequestWriter {
public static final Charset UTF_8 = Charset.forName("UTF-8");
public Collection<ContentStream> getContentStreams(SolrRequest req) throws IOException {
if (req instanceof UpdateRequest) {
@ -66,7 +68,7 @@ public class RequestWriter {
public void write(SolrRequest request, OutputStream os) throws IOException {
if (request instanceof UpdateRequest) {
UpdateRequest updateRequest = (UpdateRequest) request;
OutputStreamWriter writer = new OutputStreamWriter(os, "UTF-8");
OutputStreamWriter writer = new OutputStreamWriter(os, UTF_8);
updateRequest.writeXML(writer);
writer.flush();
}