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:
parent
f4d1895399
commit
4574489c27
|
@ -27,13 +27,6 @@ import org.apache.lucene.util.UnicodeUtil;
|
|||
*/
|
||||
public class StringRestResponse extends Utf8RestResponse {
|
||||
|
||||
private static ThreadLocal<BytesRef> cache = new ThreadLocal<BytesRef>() {
|
||||
@Override
|
||||
protected BytesRef initialValue() {
|
||||
return new BytesRef();
|
||||
}
|
||||
};
|
||||
|
||||
public StringRestResponse(RestStatus status) {
|
||||
super(status);
|
||||
}
|
||||
|
@ -43,7 +36,7 @@ public class StringRestResponse extends Utf8RestResponse {
|
|||
}
|
||||
|
||||
private static BytesRef convert(String content) {
|
||||
BytesRef result = cache.get();
|
||||
BytesRef result = new BytesRef();
|
||||
UnicodeUtil.UTF16toUTF8(content, 0, content.length(), result);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -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}.
|
||||
* <p/>
|
||||
* <p>Note, this class assumes that the utf8 result is not thread safe.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class Utf8RestResponse extends AbstractRestResponse implements RestResponse {
|
||||
|
||||
|
@ -58,7 +56,7 @@ public class Utf8RestResponse extends AbstractRestResponse implements RestRespon
|
|||
|
||||
@Override
|
||||
public boolean contentThreadSafe() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue