|
|
|
@ -37,8 +37,6 @@ class LeakAwareDataBuffer implements PooledDataBuffer { |
|
|
|
|
|
|
|
|
|
|
|
private final LeakAwareDataBufferFactory dataBufferFactory; |
|
|
|
private final LeakAwareDataBufferFactory dataBufferFactory; |
|
|
|
|
|
|
|
|
|
|
|
private int refCount = 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LeakAwareDataBuffer(DataBuffer delegate, LeakAwareDataBufferFactory dataBufferFactory) { |
|
|
|
LeakAwareDataBuffer(DataBuffer delegate, LeakAwareDataBufferFactory dataBufferFactory) { |
|
|
|
Assert.notNull(delegate, "Delegate must not be null"); |
|
|
|
Assert.notNull(delegate, "Delegate must not be null"); |
|
|
|
@ -67,19 +65,24 @@ class LeakAwareDataBuffer implements PooledDataBuffer { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean isAllocated() { |
|
|
|
public boolean isAllocated() { |
|
|
|
return this.refCount > 0; |
|
|
|
return this.delegate instanceof PooledDataBuffer && |
|
|
|
|
|
|
|
((PooledDataBuffer) this.delegate).isAllocated(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public PooledDataBuffer retain() { |
|
|
|
public PooledDataBuffer retain() { |
|
|
|
this.refCount++; |
|
|
|
if (this.delegate instanceof PooledDataBuffer) { |
|
|
|
|
|
|
|
((PooledDataBuffer) this.delegate).retain(); |
|
|
|
|
|
|
|
} |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean release() { |
|
|
|
public boolean release() { |
|
|
|
this.refCount--; |
|
|
|
if (this.delegate instanceof PooledDataBuffer) { |
|
|
|
return this.refCount == 0; |
|
|
|
((PooledDataBuffer) this.delegate).release(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return isAllocated(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// delegation
|
|
|
|
// delegation
|
|
|
|
|