davsclaus commented on code in PR #27900:
URL: https://github.com/apache/camel/pull/27900#discussion_r4284276208


##########
components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackUtil.java:
##########
@@ -74,14 +74,18 @@ protected void initChannel(Channel ch) throws Exception {
                         pipeline.addLast(new SslHandler(sslEngine));
                     }
 
-                    // Add the response recorder
+                    // Add the response recorder.
+                    // Each ACK frame is exactly 6 bytes: 1 version + 1 
type('A') + 4 sequence.
+                    // TCP may coalesce multiple ACKs into one ByteBuf, so 
drain all of them.
                     pipeline.addLast(new 
SimpleChannelInboundHandler<ByteBuf>() {
                         @Override
                         protected void channelRead0(ChannelHandlerContext ctx, 
ByteBuf msg) {
-                            assertEquals(msg.readUnsignedByte(), (short) '2');
-                            assertEquals(msg.readUnsignedByte(), (short) 'A');
-                            synchronized (responses) {
-                                responses.add(msg.readInt());
+                            while (msg.readableBytes() >= 6) {

Review Comment:
   This handles several ACKs in one buffer, but not an ACK split across two 
reads: the remaining 1 to 5 bytes are dropped when the buffer is released. A 
frame decoder in front of the handler turns the stream into whole 6-byte 
frames, so the handler can read exactly one ACK per call, as before:
   
   ```java
   pipeline.addLast(new FixedLengthFrameDecoder(6)); // io.netty.handler.codec, 
via netty-handler
   pipeline.addLast(new SimpleChannelInboundHandler<ByteBuf>() {
       @Override
       protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) {
           assertEquals((short) '2', msg.readUnsignedByte());
           assertEquals((short) 'A', msg.readUnsignedByte());
           synchronized (responses) {
               responses.add(msg.readInt());
           }
       }
   });
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to