oscerd opened a new pull request, #28846:
URL: https://github.com/apache/camel/pull/28846

   Jira: https://issues.apache.org/jira/browse/CAMEL-26481
   
   ### Problem
   
   In `camel-syslog`, `Rfc5425FrameDecoder` decodes octet-counting frames over 
Netty TCP connections.
   
   When incoming bytes end inside a length field before the space delimiter 
(for instance when a TCP segment ends after frame content and contains only 
initial digits of the next frame length):
   - `indexOf(in, ' ')` returns `-1`.
   - `lengthbuffer` remains empty, causing `Integer.parseInt("")` to throw a 
`NumberFormatException`.
   - The decoder catches the exception and executes `in.resetReaderIndex()`.
   
   Because `in.markReaderIndex()` was not set after completing earlier frames, 
`in.resetReaderIndex()` rewound `readerIndex` back to index 0 of the Netty 
cumulation buffer, causing the decoder to re-process and re-emit previously 
decoded frames repeatedly. Additionally, `in.readBytes(index)` allocated an 
intermediate buffer that was not released.
   
   ### Change
   
   - In `Rfc5425FrameDecoder.decode`:
     - Check whether the space delimiter is present before parsing the length 
field; if absent, return immediately without altering `readerIndex` so Netty 
can cumulate additional incoming bytes.
     - Parse length digits directly from the buffer without allocating 
unreleased `ByteBuf` instances.
     - Throw `IllegalArgumentException` on invalid or empty length fields.
     - Advance `readerIndex` past the length and delimiter once confirmed.
   - Added unit tests in `Rfc5425FrameDecoderTest` covering fragmented length 
fields across chunks and multi-digit length fragmentation.
   
   _Claude Code on behalf of oscerd_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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