{
inputBbAddress = System.identityHashCode(bbwi.byteBuffer);
}
ByteBufferWithInfo abbwi = null;
ByteBufferPool byteBufferPool = getByteBufferPool();
while (fragmentQueue.size() != 0)
{
abbwi = fragmentQueue.dequeue();
if (abbwi != null && abbwi.byteBuffer != null)
{
int bbAddress = System.identityHashCode(abbwi.byteBuffer);
if (inputBbAddress != bbAddress)
{
if (debug)
{
// print address of ByteBuffer released
StringBuffer sb = new StringBuffer(80);
sb.append("close() - fragmentQueue is ")
.append("releasing ByteBuffer id (")
.append(bbAddress).append(") to ")
.append("ByteBufferPool.");
String msg = sb.toString();
dprint(msg);
}
}
byteBufferPool.releaseByteBuffer(abbwi.byteBuffer);
}
}
}
fragmentQueue = null;
}
// release ByteBuffers on fragmentStack
if (fragmentStack != null && fragmentStack.size() != 0)
{
// IMPORTANT: The fragment stack may have one ByteBuffer
// on it that's also on the CDRInputStream if
// this method is called when the stream is 'marked'.
// Thus, we'll compare the ByteBuffer passed
// in (from a CDRInputStream) with all ByteBuffers
// on the stack. If one is found to equal, it will
// not be released to the ByteBufferPool.
if (bbwi != null)
{
inputBbAddress = System.identityHashCode(bbwi.byteBuffer);
}
ByteBufferWithInfo abbwi = null;
ByteBufferPool byteBufferPool = getByteBufferPool();
ListIterator itr = fragmentStack.listIterator();
while (itr.hasNext())
{
abbwi = (ByteBufferWithInfo)itr.next();
if (abbwi != null && abbwi.byteBuffer != null)
{
int bbAddress = System.identityHashCode(abbwi.byteBuffer);
if (inputBbAddress != bbAddress)
{
if (debug)
{
// print address of ByteBuffer being released
StringBuffer sb = new StringBuffer(80);
sb.append("close() - fragmentStack - releasing ")
.append("ByteBuffer id (" + bbAddress + ") to ")
.append("ByteBufferPool.");
String msg = sb.toString();
dprint(msg);
}
byteBufferPool.releaseByteBuffer(abbwi.byteBuffer);
}
}
}
fragmentStack = null;
}