From 5f8fef52a2a66e2099cf63d5244c202c6a2dd95e Mon Sep 17 00:00:00 2001 From: Lari Hotari Date: Sat, 3 Feb 2024 11:43:28 +0200 Subject: [PATCH] Properly handle the depth increase and decrease --- .../main/java/org/apache/bookkeeper/util/ByteBufVisitor.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 7fff2af79fb..60ab7a24282 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 @@ -124,7 +124,6 @@ public void visitBuffer(InternalContext internalContext, ByteBuf visitBuffer, internalContext.userCallback.visitBuffer(internalContext.userContext, visitBuffer, visitIndex, visitLength); } else { - internalContext.depth++; // use the doRecursivelyVisitBuffers method to visit the wrapped buffer, possibly recursively doRecursivelyVisitBuffers(visitBuffer, visitIndex, visitLength, this, internalContext); } @@ -152,7 +151,9 @@ private static void doRecursivelyVisitBuffers(ByteBuf buffer, int offset, in internalContext.parentBuffer = buffer; internalContext.parentOffset = offset; internalContext.parentLength = length; + internalContext.depth++; visitBuffersImpl(buffer, offset, length, callback, internalContext); + internalContext.depth--; } else { // visit the buffer internalContext.userCallback.visitBuffer(internalContext.userContext, buffer, offset, length);