make utf8 bytes response not reuse thread local buffer

no need, optimized conversion to bytes anyhow, and when sending, it will just get wrapped by a buffer
This commit is contained in:
Shay Banon 2013-07-06 10:42:34 -07:00
parent f4d1895399
commit 4574489c27
2 changed files with 2 additions and 11 deletions

View File

@ -27,13 +27,6 @@ import org.apache.lucene.util.UnicodeUtil;
*/ */
public class StringRestResponse extends Utf8RestResponse { public class StringRestResponse extends Utf8RestResponse {
private static ThreadLocal<BytesRef> cache = new ThreadLocal<BytesRef>() {
@Override
protected BytesRef initialValue() {
return new BytesRef();
}
};
public StringRestResponse(RestStatus status) { public StringRestResponse(RestStatus status) {
super(status); super(status);
} }
@ -43,7 +36,7 @@ public class StringRestResponse extends Utf8RestResponse {
} }
private static BytesRef convert(String content) { private static BytesRef convert(String content) {
BytesRef result = cache.get(); BytesRef result = new BytesRef();
UnicodeUtil.UTF16toUTF8(content, 0, content.length(), result); UnicodeUtil.UTF16toUTF8(content, 0, content.length(), result);
return result; return result;
} }

View File

@ -25,8 +25,6 @@ import org.apache.lucene.util.BytesRef;
* An http response that is built on top of {@link org.apache.lucene.util.BytesRef}. * An http response that is built on top of {@link org.apache.lucene.util.BytesRef}.
* <p/> * <p/>
* <p>Note, this class assumes that the utf8 result is not thread safe. * <p>Note, this class assumes that the utf8 result is not thread safe.
*
*
*/ */
public class Utf8RestResponse extends AbstractRestResponse implements RestResponse { public class Utf8RestResponse extends AbstractRestResponse implements RestResponse {
@ -58,7 +56,7 @@ public class Utf8RestResponse extends AbstractRestResponse implements RestRespon
@Override @Override
public boolean contentThreadSafe() { public boolean contentThreadSafe() {
return false; return true;
} }
@Override @Override