This is an automated email from the ASF dual-hosted git repository.
shoothzj pushed a commit to branch branch-4.16
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/branch-4.16 by this push:
new 6ea6de7577 Remove unused code from ByteBufVisitor (#4383)
6ea6de7577 is described below
commit 6ea6de757774bd9460faef567e1161f0ff35f61a
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();