#88: Applied a patch from @ewencp to fix missing reference problem of CachedBufferAllocator
This commit is contained in:
parent
7b86642f75
commit
dfc9322a5b
|
@ -29,10 +29,16 @@ public class CachedBufferAllocator implements BufferAllocator {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized CachedBufferAllocator getAllocator(int bufferSize) {
|
public static synchronized CachedBufferAllocator getAllocator(int bufferSize) {
|
||||||
if(!queueTable.containsKey(bufferSize)) {
|
CachedBufferAllocator result = null;
|
||||||
queueTable.put(bufferSize, new SoftReference<CachedBufferAllocator>(new CachedBufferAllocator(bufferSize)));
|
|
||||||
|
if (queueTable.containsKey(bufferSize)) {
|
||||||
|
result = queueTable.get(bufferSize).get();
|
||||||
}
|
}
|
||||||
return queueTable.get(bufferSize).get();
|
if (result == null) {
|
||||||
|
result = new CachedBufferAllocator(bufferSize);
|
||||||
|
queueTable.put(bufferSize, new SoftReference<CachedBufferAllocator>(result));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue