You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Elyran Kogan (JIRA)" <ji...@apache.org> on 2014/10/08 06:39:33 UTC

[jira] [Created] (CAMEL-7894) Encoder exception after sending a message with null body

Elyran Kogan created CAMEL-7894:
-----------------------------------

             Summary: Encoder exception after sending a message with null body
                 Key: CAMEL-7894
                 URL: https://issues.apache.org/jira/browse/CAMEL-7894
             Project: Camel
          Issue Type: Bug
          Components: camel-netty4-http
    Affects Versions: 2.14.0
            Reporter: Elyran Kogan


when sending a request with a null body ( it was GET request in my case)
I got the following exception.

after investigating the issue I found that because the body is null - the request is created with type DefaultHttpRequest and not DefaultFullHttpRequest which is created when there is a body

this causes the HttpObjectEncoder to stay in a wrong state after the request is sent, because of this code:

 if (msg instanceof LastHttpContent) {
      state = ST_INIT;
}

so the next request will fail with the exception.
the workaround is simple - use an empty string as body

also - this did not happen in camel-netty-http

the exception:
Caused by: io.netty.handler.codec.EncoderException: java.lang.IllegalStateException: unexpected message type: DefaultFullHttpRequest at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107) at io.netty.channel.CombinedChannelDuplexHandler.write(CombinedChannelDuplexHandler.java:192) at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:658) at io.netty.channel.AbstractChannelHandlerContext.access$2000(AbstractChannelHandlerContext.java:32) at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.write(AbstractChannelHandlerContext.java:939) at io.netty.channel.AbstractChannelHandlerContext$WriteAndFlushTask.write(AbstractChannelHandlerContext.java:991) at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.run(AbstractChannelHandlerContext.java:924) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:380) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357) at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.IllegalStateException: unexpected message type: DefaultFullHttpRequest at io.netty.handler.codec.http.HttpObjectEncoder.encode(HttpObjectEncoder.java:63) at io.netty.handler.codec.http.HttpClientCodec$Encoder.encode(HttpClientCodec.java:106) at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89) ... 10 more




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)