Don't cache BytesRef in ThreadLocal

This commit is contained in:
Simon Willnauer 2013-08-02 20:30:40 +02:00
parent 85b7efa08b
commit 263c5808bb
1 changed files with 1 additions and 8 deletions

View File

@ -40,13 +40,6 @@ public class XContentRestResponse extends AbstractRestResponse {
System.arraycopy(U_END_JSONP.bytes, U_END_JSONP.offset, END_JSONP, 0, U_END_JSONP.length);
}
private static ThreadLocal<BytesRef> prefixCache = new ThreadLocal<BytesRef>() {
@Override
protected BytesRef initialValue() {
return new BytesRef();
}
};
private final BytesRef prefixUtf8Result;
private final RestStatus status;
@ -146,7 +139,7 @@ public class XContentRestResponse extends AbstractRestResponse {
if (callback == null) {
return null;
}
BytesRef result = prefixCache.get();
final BytesRef result = new BytesRef();
UnicodeUtil.UTF16toUTF8(callback, 0, callback.length(), result);
result.bytes[result.length] = '(';
result.length++;