Prevent bucket creation when releasing values (fatal exceptions)
@@ -308,7 +308,7 @@ public abstract class BasePool<V> implements Pool<V> {
final int bucketedSize = getBucketedSizeForValue(value);
final int sizeInBytes = getSizeInBytes(bucketedSize);
synchronized (this) {
- final Bucket<V> bucket = getBucket(bucketedSize);
+ final Bucket<V> bucket = getBucketIfPresent(bucketedSize);
if (!mInUseValues.remove(value)) {
// This value was not 'known' to the pool (i.e.) allocated via the pool.
// Something is going wrong, so let's free the value and report soft error.
@@ -595,6 +595,15 @@ public abstract class BasePool<V> implements Pool<V> {
}
}
+ /**
+ * Gets the freelist for the specified bucket if it exists.
+ *
+ * @param bucketedSize the bucket size
+ * @return the freelist for the bucket
+ */
+ private synchronized Bucket<V> getBucketIfPresent(int bucketedSize) {
+ return mBuckets.get(bucketedSize);
+ }
/**
* Gets the freelist for the specified bucket. Create the freelist if there isn't one
