question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IllegalReferenceCountException in HttpPostMultipartRequestDecoder.

See original GitHub issue

Netty version

4.1.22.Final

JVM version (e.g. java -version)

1.8.0_162

OS version (e.g. uname -a)

windows 10

The error is observed in versions 4.1.20-4.1.22

HttpPostRequestDecoder decoder = new HttpPostRequestDecoder(request);
try {
...
} finally {
	decoder.destroy();
}

When you call decoder.destroy () MixedAttribute.release () for objects is performed 2 times.

PostTest.zip

io.netty.util.IllegalReferenceCountException: refCnt: 0, increment: 1
    	at io.netty.util.AbstractReferenceCounted.release0(AbstractReferenceCounted.java:87)
    	at io.netty.util.AbstractReferenceCounted.release(AbstractReferenceCounted.java:71)
    	at io.netty.handler.codec.http.multipart.MixedAttribute.release(MixedAttribute.java:320)
    	at io.netty.handler.codec.http.multipart.HttpPostMultipartRequestDecoder.destroy(HttpPostMultipartRequestDecoder.java:947)
    	at io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.destroy(HttpPostRequestDecoder.java:247)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
danielflowercommented, Jun 17, 2018

I’m also not calling HttpData.release() so for now I’m using this workaround:

multipartRequestDecoder.getBodyHttpDatas().clear();
multipartRequestDecoder.destroy();

Maybe this is related to the unusual way I’m creating the decoder, which is to construct it from a stream (because of reasons).

multipartRequestDecoder = new HttpPostMultipartRequestDecoder(request);
byte[] buffer = new byte[16 * 1024];
int read;
while ((read = inputStream.read(buffer)) > -1) {
    if (read > 0) {
        ByteBuf content = Unpooled.copiedBuffer(buffer, 0, read);
        multipartRequestDecoder.offer(new DefaultHttpContent(content));
    }
}
multipartRequestDecoder.offer(new DefaultLastHttpContent());
1reaction
normanmaurercommented, Oct 28, 2019

I think this should be fixed now… please reopen if you still see the issue once you upgraded to latest version

Read more comments on GitHub >

github_iconTop Results From Across the Web

jooby-project/jooby - Gitter
Hi everybody, I'm using latest version of jooby 2.8.9 and I'm having all my newrelic transactions logged as /NettyDispatcher . Has someone faced ......
Read more >
HttpPostMultipartRequestDecoder (Netty API Reference (4.0 ...
Clean all HttpDatas (on Disk) for the current request. void, destroy(). Destroy the HttpPostMultipartRequestDecoder and release all it resources.
Read more >
io.netty.util.IllegalReferenceCountException: refCnt: 0 in Netty
if (outboundChannel.isActive()) { outboundChannel.writeAndFlush(msg).addListener(new ChannelFutureListener() { // Snip } ctx.
Read more >
Index (Netty API Reference (4.1.59.Final)) - javadoc.io
HttpPostMultipartRequestDecoder. Clean all HttpDatas (on Disk) for the ... IllegalReferenceCountException() - Constructor for exception io.netty.util.
Read more >
open_source_license_AirWatch_...
... io/netty/handler/codec/http/multipart/HttpPostMultipartRequestDecoder.java ... io/netty/util/IllegalReferenceCountException.java ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found