You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use netty-http-client I found this error,when I modified class ResponseHandler ,the error disappears。I do not know if this is a problem, so I will ask。My English is poor。thankx
Yes, I understand the problem, and if this fix works for you, great. Thank you for contributing the patch.
However, it is not possible to incorporate it into the code as-is, because it will break many clients which try to use the content after it has been released (that will throw an exception).
With some redesign of the API, it would be possible to change that. For now, the best approach is either to use a non-reference counted ByteBufAllocator, or for the code which receives the ByteBuf to dispose it once it knows it will not use it anymore.
@timboudreau
This increase is currently suitable for my application scenario, 1200 threads running for half an hour without leak problems。thank you for your reply。
When I use netty-http-client I found this error,when I modified class ResponseHandler ,the error disappears。I do not know if this is a problem, so I will ask。My English is poor。thankx
add :
io.netty.util.ReferenceCountUtil.release(content);
protected void internalReceive(HttpResponseStatus status, HttpHeaders headers, ByteBuf content) {
try {
if (status.code() > 399) {
onErrorResponse(status, headers, content.readCharSequence(content.readableBytes(), CharsetUtil.UTF_8).toString());
return;
}
MediaType mediaType = null;
if (headers.contains(HttpHeaderNames.CONTENT_TYPE)) {
try {
mediaType = MediaType.parse(headers.get(HttpHeaderNames.CONTENT_TYPE));
} catch (Exception ex) {
//do nothing
}
}
T o = mediaType == null ? marshallers.read(type, content) : marshallers.read(type, content, mediaType);
_doReceive(status, headers, type.cast(o));
} catch (Exception ex) {
content.resetReaderIndex();
try {
String s = Streams.readString(new ByteBufInputStream(content), "UTF-8");
onErrorResponse(HttpResponseStatus.REQUESTED_RANGE_NOT_SATISFIABLE, headers, s);
} catch (IOException ex1) {
ex.addSuppressed(ex1);
}
Exceptions.chuck(ex);
} finally {
//2018-01-24 修改测试
io.netty.util.ReferenceCountUtil.release(content);
latch.countDown();
}
}
The text was updated successfully, but these errors were encountered: