am 169ef4cc: Check for null before returing a chunk from the pool.

Merge commit '169ef4cca30c77a1a85c9684560c504a5ac230b5' into eclair-mr2-plus-aosp

* commit '169ef4cca30c77a1a85c9684560c504a5ac230b5':
  Check for null before returing a chunk from the pool.
This commit is contained in:
Patrick Scott
2009-10-19 10:13:57 -07:00
committed by Android Git Automerger

View File

@@ -114,14 +114,17 @@ class ByteArrayBuilder {
length = DEFAULT_CAPACITY;
}
synchronized (sPool) {
// Process any queued references so that sPool does not contain
// dead entries.
// Process any queued references and remove them from the pool.
processPoolLocked();
if (!sPool.isEmpty()) {
return sPool.removeFirst().get();
} else {
return new Chunk(length);
Chunk c = sPool.removeFirst().get();
// The first item may have been queued after processPoolLocked
// so check for null.
if (c != null) {
return c;
}
}
return new Chunk(length);
}
}