This is an automated email from the ASF dual-hosted git repository. shoothzj pushed a commit to branch branch-4.17 in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
commit cc76792630406d89e422a2b955378754a909c6c3 Author: Lari Hotari <[email protected]> AuthorDate: Fri May 24 14:07:00 2024 +0300 Remove unused code from ByteBufVisitor (#4383) ### Motivation ByteBufVisitor added in #4196 contains some code that isn't used and covered by unit tests. It's better to remove such code since it makes it harder to reason about the solution. The ByteBufVisitor solution will unwrap all direct buffers that can be unwrapped without the code that is to be removed. I believe that I forgot this code from some earlier phase of the solution where it was necessary to include this. I ran some local tests and didn't see that the code was used for the original purpose that it was added for (supporting read-only buffers). ### Changes Remove the unused code. (cherry picked from commit 84fd25505abced9dbe5269f421899f8c6499787e) --- .../src/main/java/org/apache/bookkeeper/util/ByteBufVisitor.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/ByteBufVisitor.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/ByteBufVisitor.java index 32e9c8c55a..4bb60f40c6 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/ByteBufVisitor.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/ByteBufVisitor.java @@ -162,12 +162,6 @@ public class ByteBufVisitor { handleArray(visitBuffer.array(), visitBuffer.arrayOffset() + visitIndex, visitLength); } else if (visitBuffer.hasMemoryAddress() && callback.acceptsMemoryAddress(callbackContext)) { callback.visitBuffer(callbackContext, visitBuffer, visitIndex, visitLength); - } else if (callback.acceptsMemoryAddress(callbackContext) && visitBuffer.isDirect() - && visitBuffer.alloc().isDirectBufferPooled()) { - // read-only buffers need to be copied before they can be directly accessed - ByteBuf copyBuffer = visitBuffer.copy(visitIndex, visitLength); - callback.visitBuffer(callbackContext, copyBuffer, 0, visitLength); - copyBuffer.release(); } else { // fallback to reading the visited buffer into the copy buffer in a loop byte[] copyBuffer = TL_COPY_BUFFER.get();
