From 263c5808bbacac28be1a57f24f072ba7b01f7310 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Fri, 2 Aug 2013 20:30:40 +0200 Subject: [PATCH] Don't cache BytesRef in ThreadLocal --- .../org/elasticsearch/rest/XContentRestResponse.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/main/java/org/elasticsearch/rest/XContentRestResponse.java b/src/main/java/org/elasticsearch/rest/XContentRestResponse.java index e61fa8d6055..2134dfe2d8d 100644 --- a/src/main/java/org/elasticsearch/rest/XContentRestResponse.java +++ b/src/main/java/org/elasticsearch/rest/XContentRestResponse.java @@ -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 prefixCache = new ThreadLocal() { - @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++;