sunil9977 commented on code in PR #4013: URL: https://github.com/apache/cassandra/pull/4013#discussion_r2022803225
########## src/java/org/apache/cassandra/utils/FastByteOperations.java: ########## @@ -269,16 +271,29 @@ public void copy(ByteBuffer srcBuf, int srcPosition, ByteBuffer trgBuf, int trgP { Object src; long srcOffset; - if (srcBuf.hasArray()) + + // Heap ByteBuffer (Mutable) + if (srcBuf.hasArray() && !srcBuf.isReadOnly()) { src = srcBuf.array(); srcOffset = BYTE_ARRAY_BASE_OFFSET + srcBuf.arrayOffset(); } + // Read-Only Heap ByteBuffer (Still has hb but read-only) + else if (srcBuf.isReadOnly() && !srcBuf.isDirect()) + { + src = theUnsafe.getObject(srcBuf, HEAP_HB_FIELD); + srcOffset = BYTE_ARRAY_BASE_OFFSET; + + if (src == null) + throw new IllegalArgumentException("Unsupported ByteBuffer type: No backing array and not direct."); Review Comment: Yes, I just wanted to be sure we do not crash. But yes it makes sense. -- 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: pr-unsubscr...@cassandra.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For additional commands, e-mail: pr-h...@cassandra.apache.org