Index: /Users/osi/java/src/mina-trunk/core/src/test/java/org/apache/mina/common/ByteBufferTest.java
===================================================================
--- /Users/osi/java/src/mina-trunk/core/src/test/java/org/apache/mina/common/ByteBufferTest.java	(revision 383230)
+++ /Users/osi/java/src/mina-trunk/core/src/test/java/org/apache/mina/common/ByteBufferTest.java	(working copy)
@@ -22,6 +22,7 @@
 import java.nio.charset.Charset;
 import java.nio.charset.CharsetDecoder;
 import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CharacterCodingException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -524,4 +525,37 @@
         Assert.assertEquals( 10, buf.limit() );
         Assert.assertEquals( 10, buf.capacity() );
     }
+
+	public void testWideUtf8Characters() throws Exception {
+		Runnable r = new Runnable() {
+			public void run() {
+				ByteBuffer buffer = ByteBuffer.allocate( 1 );
+				buffer.setAutoExpand( true );
+
+				Charset charset = Charset.forName( "UTF-8" );
+
+				CharsetEncoder encoder = charset.newEncoder();
+
+				for ( int i = 0; i < 5; i++ ) {
+					System.out.println( i );
+					try {
+						buffer.putString( "\u89d2", encoder );
+					} catch( CharacterCodingException e ) {
+						fail( e.getMessage() );
+					}
+				}
+			}
+		};
+
+		Thread t = new Thread( r );
+		t.start();
+
+		Thread.sleep( 5 * 1000 );
+
+		if( t.isAlive() ) {
+			t.interrupt();
+
+			fail( "Went into endless loop trying to encode character");
+		}
+	}
 }
