[ 
https://issues.apache.org/jira/browse/CAMEL-26137?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18137270#comment-18137270
 ] 

Claus Ibsen commented on CAMEL-26137:
-------------------------------------

PR: https://github.com/apache/camel/pull/29103

# A List reply is now written as its toString(), as a Map or a POJO is. Since 
CAMEL-26504 it was answered with 500.
# With disableStreamCache=true, a reply that sends the request ByteBuf back now 
writes a retained duplicate of it, so the echo gets its response.
# sync=false: CAMEL-26136 already made the shared ClientChannelHandler ignore 
the response. One gap was left: the camel-netty producer created an empty out 
message on an InOut exchange, so the exchange continued with an empty body 
(netty and netty-http). It now reads the close header from the current message.

_Claude Code on behalf of Claus Ibsen (davsclaus)_

> camel-netty-http - a List reply sends no response, and echoing the request 
> body with disableStreamCache=true fails with IllegalReferenceCountException
> ------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-26137
>                 URL: https://issues.apache.org/jira/browse/CAMEL-26137
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-netty-http
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 4.24.0
>
>
> Found while adding the catalog body types of netty-http (CAMEL-24961, PR 
> #28395).
> h4. 1. A List reply sends no response and keeps the connection open
> {{DefaultNettyHttpBinding.toNettyResponse}} (main 2a465aa4814c, lines 
> 520-524) converts the reply body with {{getBody(ByteBuf.class)}} and 
> {{getBody(byte[].class)}}; for a List the array type converter fails with 
> "argument type mismatch". The exception is thrown from 
> {{ServerChannelHandler.sendResponse}}, only logged as a WARN, and no HTTP 
> response is written, so the client waits with the connection open. Checked on 
> 4.24.0-SNAPSHOT with a netty-http consumer over real sockets.
> Proposed: when the body cannot be converted to bytes, write it as its String 
> form (or reply 500) instead of writing nothing.
> h4. 2. With disableStreamCache=true, replying with the request body fails 
> with IllegalReferenceCountException
> With {{disableStreamCache=true}} the body is the request {{ByteBuf}} (line 
> 107), released by an on-completion (line 114). A route that replies with that 
> body unchanged (an echo) has {{toNettyResponse}} write the same {{ByteBuf}} 
> (line 514) and the write fails with {{IllegalReferenceCountException: refCnt: 
> 0}}; no response is sent. Checked on 4.24.0-SNAPSHOT with a netty-http 
> consumer over real sockets.
> Proposed: retain the buffer (or write a retained duplicate) when the response 
> body is the request's {{ByteBuf}}.
> h4. 3. With sync=false the producer still puts the response on the exchange
> {{HttpClientChannelHandler}} extends {{ClientChannelHandler}}, whose 
> {{channelRead0}} (line 189) sets the response on the exchange even when 
> {{sync=false}}, after the producer has completed. Checked on 4.24.0-SNAPSHOT 
> with the netty-http producer over real sockets.
> Proposed: ignore the response when {{sync=false}} (the same fix as in 
> camel-netty).
> _Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to