Index: /home/mag/svn/mina-0.7.x/src/java/org/apache/mina/common/ByteBuffer.java
===================================================================
--- /home/mag/svn/mina-0.7.x/src/java/org/apache/mina/common/ByteBuffer.java	(revision 220332)
+++ /home/mag/svn/mina-0.7.x/src/java/org/apache/mina/common/ByteBuffer.java	(working copy)
@@ -87,36 +87,6 @@
  *   <li>You called {@link #acquire()} to prevent the buffer from being released.</li>
  * </ul>
  * 
- * <h2>Wrapping existing NIO buffers and arrays</h2>
- * <p>
- * This class provides a few <tt>wrap(...)</tt> methods that wraps
- * any NIO buffers and byte arrays.  But please be careful and use these
- * methods at your own risk.  Using those methods can cause memory leakage
- * if you keep wrapping new NIO buffers and arrays because even wrapped
- * MINA buffers are going to be pooled when they are released by MINA.
- * <p>
- * To resolve this issue, please do not keeping wrapping NIO buffers if
- * possible.  If you're working with any third party component that keeps
- * creating NIO buffers, please call {@link #acquire()} once more and
- * don't call {@link #release()} for it, then it will not be returned to
- * the pool and GC'd eventually.  Here's the example:
- * <pre>
- * import org.apache.mina.common.*;
- * import org.apache.mina.io.*;
- *
- * IoSession session = ...;
- * for (;;) {
- *     // readData() returns a newly allocate NIO buffer.
- *     java.nio.ByteBuffer newBuffer = otherApplication.readData();
- *     
- *     // Wrap it.
- *     ByteBuffer wrappedBuffer = ByteBuffer.wrap(newBuffer);
- *     // Acquire once and don't call release to prevent MINA from pooling it. 
- *     wrappedBuffer.acquire();
- *     session.write(wrappedBuffer, marker);
- * }
- * </pre>
- * 
  * <h2>AutoExpand</h2>
  * <p>
  * Writing variable-length data using NIO <tt>ByteBuffers</tt> is not really
@@ -266,8 +236,8 @@
      * Wraps the specified byte array into MINA heap buffer.
      */
     public static ByteBuffer wrap( byte[] byteArray )
-    {
-        return wrap( java.nio.ByteBuffer.wrap( byteArray ) );
+    {       
+       return wrap( byteArray, 0, byteArray.length );
     }
     
     /**
@@ -278,7 +248,8 @@
      */
     public static ByteBuffer wrap( byte[] byteArray, int offset, int length )
     {
-        return wrap( java.nio.ByteBuffer.wrap( byteArray, offset, length ) );
+       ByteBuffer buf = allocate(length);
+       return buf.put( byteArray, offset, length ).flip();
     }
     
     private static int getBufferStackIndex( Stack[] bufferStacks, int size )
