-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#12082 - fix DynamicCapacity.release()
Signed-off-by: Ludovic Orban <[email protected]>
- Loading branch information
Showing
3 changed files
with
64 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
jetty-core/jetty-io/src/test/java/org/eclipse/jetty/io/DynamicCapacityTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// ======================================================================== | ||
// | ||
|
||
package org.eclipse.jetty.io; | ||
|
||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.is; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class DynamicCapacityTest | ||
{ | ||
private ArrayByteBufferPool.Tracking _pool; | ||
|
||
@BeforeEach | ||
public void beforeAll() | ||
{ | ||
_pool = new ArrayByteBufferPool.Tracking(); | ||
} | ||
|
||
@AfterEach | ||
public void afterAll() | ||
{ | ||
assertThat("Leaks: " + _pool.dumpLeaks(), _pool.getLeaks().size(), is(0)); | ||
} | ||
|
||
@Test | ||
public void testReuseAfterRelease() | ||
{ | ||
RetainableByteBuffer.Mutable accumulator = new RetainableByteBuffer.DynamicCapacity(_pool); | ||
|
||
accumulator.putInt(1); | ||
assertTrue(accumulator.hasRemaining()); | ||
assertTrue(accumulator.release()); | ||
assertFalse(accumulator.hasRemaining()); | ||
|
||
accumulator.putInt(1); | ||
assertTrue(accumulator.hasRemaining()); | ||
assertTrue(accumulator.release()); | ||
assertFalse(accumulator.hasRemaining()); | ||
} | ||
} |