directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r370444 - in /directory/trunks/mina/core/src: main/java/org/apache/mina/common/ByteBuffer.java test/java/org/apache/mina/common/ByteBufferTest.java
Date Thu, 19 Jan 2006 08:45:12 GMT
Author: trustin
Date: Thu Jan 19 00:45:05 2006
New Revision: 370444

URL: http://svn.apache.org/viewcvs?rev=370444&view=rev
Log:
Applied Peter Royal's patch for DIRMINA-164 (ByteBuffer.getString() adds a null when null-padded
and at end of buffer)


Modified:
    directory/trunks/mina/core/src/main/java/org/apache/mina/common/ByteBuffer.java
    directory/trunks/mina/core/src/test/java/org/apache/mina/common/ByteBufferTest.java

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/ByteBuffer.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/main/java/org/apache/mina/common/ByteBuffer.java?rev=370444&r1=370443&r2=370444&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/ByteBuffer.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/ByteBuffer.java Thu Jan
19 00:45:05 2006
@@ -933,7 +933,7 @@
             }
 
             end = position();
-            if( end == oldLimit )
+            if( end == oldLimit && get( end - 1 ) != 0 )
             {
                 limit( end );
             }

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/common/ByteBufferTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/test/java/org/apache/mina/common/ByteBufferTest.java?rev=370444&r1=370443&r2=370444&view=diff
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/common/ByteBufferTest.java (original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/common/ByteBufferTest.java Thu
Jan 19 00:45:05 2006
@@ -166,7 +166,20 @@
         ByteBuffer buf = ByteBuffer.allocate( 16 );
         CharsetDecoder decoder;
 
+        Charset charset = Charset.forName( "UTF-8" );
+        buf.clear();
+        buf.putString( "hello", charset.newEncoder() );
+        buf.put( (byte)0 );
+        buf.flip();
+        Assert.assertEquals( "hello", buf.getString( charset.newDecoder() ) );
+        
+        buf.clear();
+        buf.putString( "hello", charset.newEncoder() );
+        buf.flip();
+        Assert.assertEquals( "hello", buf.getString( charset.newDecoder() ) );
+
         decoder = Charset.forName( "ISO-8859-1" ).newDecoder();
+        buf.clear();
         buf.put( (byte) 'A' );
         buf.put( (byte) 'B' );
         buf.put( (byte) 'C' );



Mime
View raw message