You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by tr...@apache.org on 2006/11/20 06:06:08 UTC
svn commit: r477045 -
/mina/trunk/core/src/main/java/org/apache/mina/common/SimpleByteBufferAllocator.java
Author: trustin
Date: Sun Nov 19 21:06:05 2006
New Revision: 477045
URL: http://svn.apache.org/viewvc?view=rev&rev=477045
Log:
Reverted back SimpleByteBuffer to avoid test failures
Modified:
mina/trunk/core/src/main/java/org/apache/mina/common/SimpleByteBufferAllocator.java
Modified: mina/trunk/core/src/main/java/org/apache/mina/common/SimpleByteBufferAllocator.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/SimpleByteBufferAllocator.java?view=diff&rev=477045&r1=477044&r2=477045
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/SimpleByteBufferAllocator.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/SimpleByteBufferAllocator.java Sun Nov 19 21:06:05 2006
@@ -64,19 +64,42 @@
private static class SimpleByteBuffer extends BaseByteBuffer
{
private java.nio.ByteBuffer buf;
+ private int refCount = 1;
protected SimpleByteBuffer( java.nio.ByteBuffer buf )
{
this.buf = buf;
buf.order( ByteOrder.BIG_ENDIAN );
+ refCount = 1;
}
- public void acquire()
+ public synchronized void acquire()
{
+ if( refCount <= 0 )
+ {
+ throw new IllegalStateException( "Already released buffer." );
+ }
+
+ refCount ++;
}
public void release()
{
+ synchronized( this )
+ {
+ if( refCount <= 0 )
+ {
+ refCount = 0;
+ throw new IllegalStateException(
+ "Already released buffer. You released the buffer too many times." );
+ }
+
+ refCount --;
+ if( refCount > 0)
+ {
+ return;
+ }
+ }
}
public java.nio.ByteBuffer buf()