You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by tr...@apache.org on 2005/05/17 07:34:04 UTC

svn commit: r170516 - in /directory/network: branches/api_integration/src/java/org/apache/mina/common/ByteBuffer.java trunk/src/java/org/apache/mina/common/ByteBuffer.java

Author: trustin
Date: Mon May 16 22:34:03 2005
New Revision: 170516

URL: http://svn.apache.org/viewcvs?rev=170516&view=rev
Log:
Fixed: DIRMINA-41


Modified:
    directory/network/branches/api_integration/src/java/org/apache/mina/common/ByteBuffer.java
    directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java

Modified: directory/network/branches/api_integration/src/java/org/apache/mina/common/ByteBuffer.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/api_integration/src/java/org/apache/mina/common/ByteBuffer.java?rev=170516&r1=170515&r2=170516&view=diff
==============================================================================
--- directory/network/branches/api_integration/src/java/org/apache/mina/common/ByteBuffer.java (original)
+++ directory/network/branches/api_integration/src/java/org/apache/mina/common/ByteBuffer.java Mon May 16 22:34:03 2005
@@ -70,8 +70,8 @@
  * 
  * <h2>Acquire/Release</h2>
  * <p>
- * <b>Please note that you never need to release the allocated buffer because
- * MINA will release it automatically when:
+ * <b>Please note that you never need to release the allocated buffer</b>
+ * because MINA will release it automatically when:
  * <ul>
  *   <li>You pass the buffer by calling {@link IoSession#write(Object)}.</li>
  *   <li>You pass the buffer by calling {@link NextFilter#filterWrite(IoSession,Object)}.</li>
@@ -168,8 +168,14 @@
     public static ByteBuffer allocate( int capacity, boolean direct )
     {
         java.nio.ByteBuffer nioBuffer = allocate0( capacity, direct );
+        DefaultByteBuffer buf = allocateContainer();
+        buf.init( nioBuffer );
+        return buf;
+    }
+
+    private static DefaultByteBuffer allocateContainer()
+    {
         DefaultByteBuffer buf;
-        
         synchronized( containerStack )
         {
             buf = ( DefaultByteBuffer ) containerStack.pop();
@@ -179,8 +185,6 @@
         {
             buf = new DefaultByteBuffer();
         }
-
-        buf.init( nioBuffer );
         return buf;
     }
     
@@ -224,7 +228,7 @@
      */
     public static ByteBuffer wrap( java.nio.ByteBuffer nioBuffer )
     {
-        DefaultByteBuffer buf = new DefaultByteBuffer();
+        DefaultByteBuffer buf = allocateContainer();
         buf.init( nioBuffer );
         return buf;
     }

Modified: directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java?rev=170516&r1=170515&r2=170516&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java Mon May 16 22:34:03 2005
@@ -71,8 +71,8 @@
  * 
  * <h2>Acquire/Release</h2>
  * <p>
- * <b>Please note that you never need to release the allocated buffer because
- * MINA will release it automatically when:
+ * <b>Please note that you never need to release the allocated buffer</b>
+ * because MINA will release it automatically when:
  * <ul>
  *   <li>You pass the buffer by calling {@link IoSession#write(ByteBuffer, Object)}.</li>
  *   <li>You pass the buffer by calling {@link ProtocolEncoderOutput#write(ByteBuffer)}.</li>
@@ -168,8 +168,14 @@
     public static ByteBuffer allocate( int capacity, boolean direct )
     {
         java.nio.ByteBuffer nioBuffer = allocate0( capacity, direct );
+        DefaultByteBuffer buf = allocateContainer();
+        buf.init( nioBuffer );
+        return buf;
+    }
+
+    private static DefaultByteBuffer allocateContainer()
+    {
         DefaultByteBuffer buf;
-        
         synchronized( containerStack )
         {
             buf = ( DefaultByteBuffer ) containerStack.pop();
@@ -179,8 +185,6 @@
         {
             buf = new DefaultByteBuffer();
         }
-
-        buf.init( nioBuffer );
         return buf;
     }
     
@@ -226,7 +230,7 @@
      */
     public static ByteBuffer wrap( java.nio.ByteBuffer nioBuffer )
     {
-        DefaultByteBuffer buf = new DefaultByteBuffer();
+        DefaultByteBuffer buf = allocateContainer();
         buf.init( nioBuffer );
         return buf;
     }