Skip to content

Commit

Permalink
#12790 fix remove stats
Browse files Browse the repository at this point in the history
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
  • Loading branch information
lorban committed Mar 3, 2025
1 parent 6f39fa4 commit 354c317
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import java.util.function.IntUnaryOperator;
import java.util.function.ToLongFunction;
import java.util.stream.Collectors;

import org.eclipse.jetty.io.internal.CompoundPool;
import org.eclipse.jetty.io.internal.QueuedPool;
import org.eclipse.jetty.util.BufferUtil;
Expand Down Expand Up @@ -308,7 +307,11 @@ private void release(RetainedBucket bucket, Pool.Entry<RetainableByteBuffer> ent

RetainableByteBuffer buffer = entry.getPooled();
if (buffer == null)
{
// Removed before being released, record removal.
bucket.recordRemove();
return;
}
BufferUtil.reset(buffer.getByteBuffer());

// Release the buffer and check the memory 1% of the times.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;

import org.eclipse.jetty.io.internal.CompoundPool;
import org.eclipse.jetty.util.ConcurrentPool;
import org.eclipse.jetty.util.Pool;
Expand Down Expand Up @@ -48,6 +47,7 @@ public void testRemoveAndReleaseFromCompoundPool()
List<RetainableByteBuffer> rbbs = new ArrayList<>();

ArrayByteBufferPool pool = new ArrayByteBufferPool();
pool.setStatisticsEnabled(true);
for (int i = 0; i < bufferCount; i++)
{
RetainableByteBuffer rbb = pool.acquire(1, false);
Expand All @@ -67,6 +67,8 @@ public void testRemoveAndReleaseFromCompoundPool()
{
assertThat(rbb.getByteBuffer(), notNullValue());
}
String dump = pool.dump();
assertThat(dump, containsString("[capacity=4096,in-use=0/0,pooled/acquires/releases=512/1024/1024(50.000%),non-pooled/evicts/removes=0/0/1024]"));
}

@Test
Expand Down

0 comments on commit 354c317

Please sign in to comment.