Claus Ibsen created CAMEL-26137:
-----------------------------------
Summary: 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
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)