Skip to content

Commit cc76792

Browse files
lhotariZhangJian He
authored andcommitted
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 84fd255)
1 parent df88638 commit cc76792

1 file changed

Lines changed: 0 additions & 6 deletions

File tree

bookkeeper-server/src/main/java/org/apache/bookkeeper/util/ByteBufVisitor.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,6 @@ private void passBufferToCallback(ByteBuf visitBuffer, int visitIndex, int visit
162162
handleArray(visitBuffer.array(), visitBuffer.arrayOffset() + visitIndex, visitLength);
163163
} else if (visitBuffer.hasMemoryAddress() && callback.acceptsMemoryAddress(callbackContext)) {
164164
callback.visitBuffer(callbackContext, visitBuffer, visitIndex, visitLength);
165-
} else if (callback.acceptsMemoryAddress(callbackContext) && visitBuffer.isDirect()
166-
&& visitBuffer.alloc().isDirectBufferPooled()) {
167-
// read-only buffers need to be copied before they can be directly accessed
168-
ByteBuf copyBuffer = visitBuffer.copy(visitIndex, visitLength);
169-
callback.visitBuffer(callbackContext, copyBuffer, 0, visitLength);
170-
copyBuffer.release();
171165
} else {
172166
// fallback to reading the visited buffer into the copy buffer in a loop
173167
byte[] copyBuffer = TL_COPY_BUFFER.get();

0 commit comments

Comments
 (0)