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