allthingssecurity commented on code in PR #27757:
URL: https://github.com/apache/camel/pull/27757#discussion_r4256023706


##########
components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyChannelBufferStreamCache.java:
##########
@@ -46,14 +46,20 @@ public NettyChannelBufferStreamCache(ByteBuf buffer) {
         this.buffer.markReaderIndex();
     }
 
+    /**
+     * Marking is not supported: {@link #mark(int)} does nothing, and {@link 
#reset()} always goes back to the start of
+     * the body, which is what {@link StreamCache#reset()} is for. A reader 
that needs mark support has to wrap this
+     * stream (for example in a {@link java.io.BufferedInputStream}), and so 
cannot change where a reset goes back to.
+     */
     @Override
     public boolean markSupported() {
-        return true;
+        return false;
     }
 
     @Override
     public int read() {
-        return buffer.readByte();
+        // an unsigned byte, and -1 at the end, as InputStream requires
+        return buffer.isReadable() ? buffer.readByte() & 0xFF : -1;
     }

Review Comment:
   Agreed, `available()` should return `buffer.readableBytes()`. The PR was 
merged before I pushed it, so it will be
   handled in a follow-up PR, with a test.
   
   _Claude Code on behalf of allthingssecurity_



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