CompositeLeakyBucket implements LeakyBucket, Startable, Stoppable { @Override public void release() { if(closed.get()) { return; } origin.release(); } CompositeLeakyBucket(KeeperConfig keeperConfig, MetaServerKeeperService metaServerKeeperService,
                                KeeperContainerService keeperContainerService); @Override boolean tryAcquire(); @Override void release(); @Override void resize(int newSize); @Override int references(); @Override int getTotalSize(); @Override void start(); @Override void stop(); boolean isClosed();  }
@Test public void testRelease() throws InterruptedException { int task = 3 * 100; CountDownLatch latch = new CountDownLatch(task); for (int i = 0; i < task; i++) { executors.execute(new Runnable() { @Override public void run() { if (leakyBucket.tryAcquire()) { leakyBucket.release(); } latch.countDown(); } }); } latch.await(10000, TimeUnit.MILLISECONDS); assertEquals(3, leakyBucket.references()); }