org.jboss.resteasy.spi.ReaderException: io.netty.util.IllegalReferenceCountException: refCnt: 0

JBoss Issue Tracker | Álvaro Pereda | 2 years ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    Trying to do a POST request against netty 4.0.23 I get an IllegalReferenceCountException: refCnt: 0, while if I run the same code against resteasy-netty4 3.0.8.Final, there are not issues. MyForm: ... @FormParam(FILE_NAME_PARAM) @PartType(MediaType.APPLICATION_OCTET_STREAM) public void setFileData(byte[] fileData) { this.fileData = fileData; } MyResource: ... @POST @Path(MY_PATH) @Consumes(MediaType.MULTIPART_FORM_DATA) public Response handleForm(@MultipartForm MyForm form) { ... } Exception: org.jboss.resteasy.spi.ReaderException: io.netty.util.IllegalReferenceCountException: refCnt: 0 at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:183) ~[resteasy-jaxrs-3.0.9.Final.jar:na] at org.jboss.resteasy.core.MethodInjectorImpl.injectArguments(MethodInjectorImpl.java:89) ~[resteasy-jaxrs-3.0.9.Final.jar:na] at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:112) ~[resteasy-jaxrs-3.0.9.Final.jar:na] at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:296) ~[resteasy-jaxrs-3.0.9.Final.jar:na] at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:250) ~[resteasy-jaxrs-3.0.9.Final.jar:na] at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:237) ~[resteasy-jaxrs-3.0.9.Final.jar:na] at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356) [resteasy-jaxrs-3.0.9.Final.jar:na] at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179) [resteasy-jaxrs-3.0.9.Final.jar:na] at org.jboss.resteasy.plugins.server.netty.RequestDispatcher.service(RequestDispatcher.java:83) [resteasy-netty4-3.0.9.Final.jar:na] at org.jboss.resteasy.plugins.server.netty.RequestHandler.channelRead0(RequestHandler.java:53) [resteasy-netty4-3.0.9.Final.jar:na] at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [netty-all-4.0.23.Final.jar:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333) [netty-all-4.0.23.Final.jar:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.access$700(AbstractChannelHandlerContext.java:32) [netty-all-4.0.23.Final.jar:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext$8.run(AbstractChannelHandlerContext.java:324) [netty-all-4.0.23.Final.jar:4.0.23.Final] at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:380) [netty-all-4.0.23.Final.jar:4.0.23.Final] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357) [netty-all-4.0.23.Final.jar:4.0.23.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) [netty-all-4.0.23.Final.jar:4.0.23.Final] at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137) [netty-all-4.0.23.Final.jar:4.0.23.Final] at java.lang.Thread.run(Thread.java:722) [na:1.7.0_21] Caused by: io.netty.util.IllegalReferenceCountException: refCnt: 0 at io.netty.buffer.AbstractByteBuf.ensureAccessible(AbstractByteBuf.java:1187) ~[netty-all-4.0.23.Final.jar:4.0.23.Final] at io.netty.buffer.AbstractByteBuf.checkReadableBytes(AbstractByteBuf.java:1170) ~[netty-all-4.0.23.Final.jar:4.0.23.Final] at io.netty.buffer.AbstractByteBuf.readBytes(AbstractByteBuf.java:676) ~[netty-all-4.0.23.Final.jar:4.0.23.Final] at io.netty.buffer.CompositeByteBuf.readBytes(CompositeByteBuf.java:1461) ~[netty-all-4.0.23.Final.jar:4.0.23.Final] at io.netty.buffer.CompositeByteBuf.readBytes(CompositeByteBuf.java:40) ~[netty-all-4.0.23.Final.jar:4.0.23.Final] at io.netty.buffer.ByteBufInputStream.read(ByteBufInputStream.java:120) ~[netty-all-4.0.23.Final.jar:4.0.23.Final] at java.io.SequenceInputStream.read(SequenceInputStream.java:208) ~[na:1.7.0_21] at java.io.SequenceInputStream.read(SequenceInputStream.java:211) ~[na:1.7.0_21] at org.apache.james.mime4j.io.BufferedLineReaderInputStream.fillBuffer(BufferedLineReaderInputStream.java:94) ~[apache-mime4j-0.6.jar:0.6] at org.apache.james.mime4j.io.MimeBoundaryInputStream.fillBuffer(MimeBoundaryInputStream.java:196) ~[apache-mime4j-0.6.jar:0.6] at org.apache.james.mime4j.io.MimeBoundaryInputStream.<init>(MimeBoundaryInputStream.java:75) ~[apache-mime4j-0.6.jar:0.6] at org.apache.james.mime4j.parser.MimeEntity.createMimeStream(MimeEntity.java:217) ~[apache-mime4j-0.6.jar:0.6] at org.apache.james.mime4j.parser.MimeEntity.advance(MimeEntity.java:152) ~[apache-mime4j-0.6.jar:0.6] at org.apache.james.mime4j.parser.MimeTokenStream.next(MimeTokenStream.java:356) ~[apache-mime4j-0.6.jar:0.6] at org.apache.james.mime4j.parser.MimeStreamParser.parse(MimeStreamParser.java:144) ~[apache-mime4j-0.6.jar:0.6] at org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl$BinaryMessage.<init>(MultipartInputImpl.java:153) ~[resteasy-multipart-provider-3.0.9.Final.jar:na] at org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl$BinaryMessage.<init>(MultipartInputImpl.java:146) ~[resteasy-multipart-provider-3.0.9.Final.jar:na] at org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl.parse(MultipartInputImpl.java:197) ~[resteasy-multipart-provider-3.0.9.Final.jar:na] at org.jboss.resteasy.plugins.providers.multipart.MultipartFormAnnotationReader.readFrom(MultipartFormAnnotationReader.java:55) ~[resteasy-multipart-provider-3.0.9.Final.jar:na] at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.readFrom(AbstractReaderInterceptorContext.java:59) ~[resteasy-jaxrs-3.0.9.Final.jar:na] at org.jboss.resteasy.core.interception.ServerReaderInterceptorContext.readFrom(ServerReaderInterceptorContext.java:62) ~[resteasy-jaxrs-3.0.9.Final.jar:na] at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:51) ~[resteasy-jaxrs-3.0.9.Final.jar:na] at org.jboss.resteasy.plugins.interceptors.encoding.GZIPDecodingInterceptor.aroundReadFrom(GZIPDecodingInterceptor.java:59) ~[resteasy-jaxrs-3.0.9.Final.jar:na] at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:53) ~[resteasy-jaxrs-3.0.9.Final.jar:na] at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:150) ~[resteasy-jaxrs-3.0.9.Final.jar:na] ... 18 common frames omitted It has been filed in github by other user before: https://github.com/resteasy/Resteasy/issues/583

    JBoss Issue Tracker | 2 years ago | Álvaro Pereda
    org.jboss.resteasy.spi.ReaderException: io.netty.util.IllegalReferenceCountException: refCnt: 0

    Root Cause Analysis

    1. io.netty.util.IllegalReferenceCountException

      refCnt: 0

      at io.netty.buffer.AbstractByteBuf.ensureAccessible()
    2. Netty
      ByteBufInputStream.read
      1. io.netty.buffer.AbstractByteBuf.ensureAccessible(AbstractByteBuf.java:1187)[netty-all-4.0.23.Final.jar:4.0.23.Final]
      2. io.netty.buffer.AbstractByteBuf.checkReadableBytes(AbstractByteBuf.java:1170)[netty-all-4.0.23.Final.jar:4.0.23.Final]
      3. io.netty.buffer.AbstractByteBuf.readBytes(AbstractByteBuf.java:676)[netty-all-4.0.23.Final.jar:4.0.23.Final]
      4. io.netty.buffer.CompositeByteBuf.readBytes(CompositeByteBuf.java:1461)[netty-all-4.0.23.Final.jar:4.0.23.Final]
      5. io.netty.buffer.CompositeByteBuf.readBytes(CompositeByteBuf.java:40)[netty-all-4.0.23.Final.jar:4.0.23.Final]
      6. io.netty.buffer.ByteBufInputStream.read(ByteBufInputStream.java:120)[netty-all-4.0.23.Final.jar:4.0.23.Final]
      6 frames
    3. Java RT
      SequenceInputStream.read
      1. java.io.SequenceInputStream.read(SequenceInputStream.java:208)[na:1.7.0_21]
      2. java.io.SequenceInputStream.read(SequenceInputStream.java:211)[na:1.7.0_21]
      2 frames
    4. JAMES
      MimeStreamParser.parse
      1. org.apache.james.mime4j.io.BufferedLineReaderInputStream.fillBuffer(BufferedLineReaderInputStream.java:94)[apache-mime4j-0.6.jar:0.6]
      2. org.apache.james.mime4j.io.MimeBoundaryInputStream.fillBuffer(MimeBoundaryInputStream.java:196)[apache-mime4j-0.6.jar:0.6]
      3. org.apache.james.mime4j.io.MimeBoundaryInputStream.<init>(MimeBoundaryInputStream.java:75)[apache-mime4j-0.6.jar:0.6]
      4. org.apache.james.mime4j.parser.MimeEntity.createMimeStream(MimeEntity.java:217)[apache-mime4j-0.6.jar:0.6]
      5. org.apache.james.mime4j.parser.MimeEntity.advance(MimeEntity.java:152)[apache-mime4j-0.6.jar:0.6]
      6. org.apache.james.mime4j.parser.MimeTokenStream.next(MimeTokenStream.java:356)[apache-mime4j-0.6.jar:0.6]
      7. org.apache.james.mime4j.parser.MimeStreamParser.parse(MimeStreamParser.java:144)[apache-mime4j-0.6.jar:0.6]
      7 frames
    5. org.jboss.resteasy
      MultipartFormAnnotationReader.readFrom
      1. org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl$BinaryMessage.<init>(MultipartInputImpl.java:153)[resteasy-multipart-provider-3.0.9.Final.jar:na]
      2. org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl$BinaryMessage.<init>(MultipartInputImpl.java:146)[resteasy-multipart-provider-3.0.9.Final.jar:na]
      3. org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl.parse(MultipartInputImpl.java:197)[resteasy-multipart-provider-3.0.9.Final.jar:na]
      4. org.jboss.resteasy.plugins.providers.multipart.MultipartFormAnnotationReader.readFrom(MultipartFormAnnotationReader.java:55)[resteasy-multipart-provider-3.0.9.Final.jar:na]
      4 frames
    6. RESTEasy JAX-RS Implementation
      SynchronousDispatcher.invoke
      1. org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.readFrom(AbstractReaderInterceptorContext.java:59)[resteasy-jaxrs-3.0.9.Final.jar:na]
      2. org.jboss.resteasy.core.interception.ServerReaderInterceptorContext.readFrom(ServerReaderInterceptorContext.java:62)[resteasy-jaxrs-3.0.9.Final.jar:na]
      3. org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:51)[resteasy-jaxrs-3.0.9.Final.jar:na]
      4. org.jboss.resteasy.plugins.interceptors.encoding.GZIPDecodingInterceptor.aroundReadFrom(GZIPDecodingInterceptor.java:59)[resteasy-jaxrs-3.0.9.Final.jar:na]
      5. org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:53)[resteasy-jaxrs-3.0.9.Final.jar:na]
      6. org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:150)[resteasy-jaxrs-3.0.9.Final.jar:na]
      7. org.jboss.resteasy.core.MethodInjectorImpl.injectArguments(MethodInjectorImpl.java:89)[resteasy-jaxrs-3.0.9.Final.jar:na]
      8. org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:112)[resteasy-jaxrs-3.0.9.Final.jar:na]
      9. org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:296)[resteasy-jaxrs-3.0.9.Final.jar:na]
      10. org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:250)[resteasy-jaxrs-3.0.9.Final.jar:na]
      11. org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:237)[resteasy-jaxrs-3.0.9.Final.jar:na]
      12. org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356)[resteasy-jaxrs-3.0.9.Final.jar:na]
      13. org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179)[resteasy-jaxrs-3.0.9.Final.jar:na]
      13 frames
    7. RESTEasy Netty Integration
      RequestHandler.channelRead0
      1. org.jboss.resteasy.plugins.server.netty.RequestDispatcher.service(RequestDispatcher.java:83)[resteasy-netty4-3.0.9.Final.jar:na]
      2. org.jboss.resteasy.plugins.server.netty.RequestHandler.channelRead0(RequestHandler.java:53)[resteasy-netty4-3.0.9.Final.jar:na]
      2 frames
    8. Netty
      DefaultThreadFactory$DefaultRunnableDecorator.run
      1. io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)[netty-all-4.0.23.Final.jar:4.0.23.Final]
      2. io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)[netty-all-4.0.23.Final.jar:4.0.23.Final]
      3. io.netty.channel.AbstractChannelHandlerContext.access$700(AbstractChannelHandlerContext.java:32)[netty-all-4.0.23.Final.jar:4.0.23.Final]
      4. io.netty.channel.AbstractChannelHandlerContext$8.run(AbstractChannelHandlerContext.java:324)[netty-all-4.0.23.Final.jar:4.0.23.Final]
      5. io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:380)[netty-all-4.0.23.Final.jar:4.0.23.Final]
      6. io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)[netty-all-4.0.23.Final.jar:4.0.23.Final]
      7. io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)[netty-all-4.0.23.Final.jar:4.0.23.Final]
      8. io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)[netty-all-4.0.23.Final.jar:4.0.23.Final]
      8 frames
    9. Java RT
      Thread.run
      1. java.lang.Thread.run(Thread.java:722)[na:1.7.0_21]
      1 frame