DeflaterPoolBenchmark should manage lifecycle of the CompressionPool

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2020-09-23 17:36:49 +10:00
parent dd06008ff4
commit ef816fcc42
2 changed files with 8 additions and 4 deletions

View File

@ -97,8 +97,11 @@ public abstract class CompressionPool<T> extends AbstractLifeCycle
@Override
public void doStop() throws Exception
{
_pool.close();
_pool = null;
if (_pool != null)
{
_pool.close();
_pool = null;
}
super.doStop();
}

View File

@ -80,16 +80,17 @@ public class DeflaterPoolBenchmark
}
_pool = new DeflaterPool(capacity, Deflater.DEFAULT_COMPRESSION, true);
_pool.start();
}
@TearDown(Level.Trial)
public static void stopTrial() throws Exception
public void stopTrial() throws Exception
{
_pool.stop();
}
@Benchmark
@BenchmarkMode({Mode.Throughput})
@SuppressWarnings("deprecation")
public long testPool() throws Exception
{
DeflaterPool.Entry entry = _pool.acquire();