if (success) {
this.totalReservoirCapacity += bb.capacity();
average = this.totalReservoirCapacity / this.buffers.size(); // size will never be 0.</BUG>
}
<BUG>} finally {
lock.unlock();
}
if (!success) {
LOG.warn("At capacity: " + this.buffers.size());
} else {
if (average > this.runningAverage && average < this.maxByteBufferSizeToCache) {
this.runningAverage = average;
}</BUG>
}

import java.util.concurrent.atomic.AtomicLong;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import com.google.common.annotations.VisibleForTesting;
@InterfaceAudience.Private
public class BoundedByteBufferPool {
private static final Log LOG = LogFactory.getLog(BoundedByteBufferPool.class);
private final Queue<ByteBuffer> buffers = new ConcurrentLinkedQueue<ByteBuffer>();
@VisibleForTesting
int getQueueSize() {
return buffers.size();
