directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r344493 - in /directory/network: branches/0.8/src/java/org/apache/mina/common/ branches/0.8/src/test/org/apache/mina/common/ trunk/src/java/org/apache/mina/common/ trunk/src/test/org/apache/mina/common/
Date Wed, 16 Nov 2005 01:36:53 GMT
Author: trustin
Date: Tue Nov 15 17:36:44 2005
New Revision: 344493

URL: http://svn.apache.org/viewcvs?rev=344493&view=rev
Log:
Found a bug in fix for DIRMINA-124: ByteBuffer.getString(...) throws an IllegalStateException
* Added a test case to make sure it is really fixed



Modified:
    directory/network/branches/0.8/src/java/org/apache/mina/common/ByteBuffer.java
    directory/network/branches/0.8/src/test/org/apache/mina/common/ByteBufferTest.java
    directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java
    directory/network/trunk/src/test/org/apache/mina/common/ByteBufferTest.java

Modified: directory/network/branches/0.8/src/java/org/apache/mina/common/ByteBuffer.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.8/src/java/org/apache/mina/common/ByteBuffer.java?rev=344493&r1=344492&r2=344493&view=diff
==============================================================================
--- directory/network/branches/0.8/src/java/org/apache/mina/common/ByteBuffer.java (original)
+++ directory/network/branches/0.8/src/java/org/apache/mina/common/ByteBuffer.java Tue Nov
15 17:36:44 2005
@@ -1086,6 +1086,8 @@
             buf.position( oldPos );
             if( !buf.hasRemaining() )
             {
+                buf.limit( oldLimit );
+                buf.position( end );
                 return "";
             }
             decoder.reset();
@@ -1199,6 +1201,8 @@
             buf.position( oldPos );
             if( !buf.hasRemaining() )
             {
+                buf.limit( oldLimit );
+                buf.position( end );
                 return "";
             }
             decoder.reset();

Modified: directory/network/branches/0.8/src/test/org/apache/mina/common/ByteBufferTest.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.8/src/test/org/apache/mina/common/ByteBufferTest.java?rev=344493&r1=344492&r2=344493&view=diff
==============================================================================
--- directory/network/branches/0.8/src/test/org/apache/mina/common/ByteBufferTest.java (original)
+++ directory/network/branches/0.8/src/test/org/apache/mina/common/ByteBufferTest.java Tue
Nov 15 17:36:44 2005
@@ -236,6 +236,20 @@
         buf.limit( 0 );
         Assert.assertEquals( "", buf.getString( decoder ) );
         Assert.assertEquals( "", buf.getString( 2, decoder ) );
+
+        // Test getting strings from non-empty buffer which is filled with 0x00
+        buf.clear();
+        buf.putInt( 0 );
+        buf.clear();
+        buf.limit( 4 );
+        Assert.assertEquals( "", buf.getString( decoder ) );
+        Assert.assertEquals( 2, buf.position() );
+        Assert.assertEquals( 4, buf.limit() );
+        
+        buf.position( 0 );
+        Assert.assertEquals( "", buf.getString( 2, decoder ) );
+        Assert.assertEquals( 2, buf.position() );
+        Assert.assertEquals( 4, buf.limit() );
     }
     
     public void testPutString() throws Exception

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=344493&r1=344492&r2=344493&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 Tue Nov 15 17:36:44
2005
@@ -1088,6 +1088,8 @@
             buf.position( oldPos );
             if( !buf.hasRemaining() )
             {
+                buf.limit( oldLimit );
+                buf.position( end );
                 return "";
             }
             decoder.reset();
@@ -1201,6 +1203,8 @@
             buf.position( oldPos );
             if( !buf.hasRemaining() )
             {
+                buf.limit( oldLimit );
+                buf.position( end );
                 return "";
             }
             decoder.reset();

Modified: directory/network/trunk/src/test/org/apache/mina/common/ByteBufferTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/common/ByteBufferTest.java?rev=344493&r1=344492&r2=344493&view=diff
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/common/ByteBufferTest.java (original)
+++ directory/network/trunk/src/test/org/apache/mina/common/ByteBufferTest.java Tue Nov 15
17:36:44 2005
@@ -236,6 +236,20 @@
         buf.limit( 0 );
         Assert.assertEquals( "", buf.getString( decoder ) );
         Assert.assertEquals( "", buf.getString( 2, decoder ) );
+        
+        // Test getting strings from non-empty buffer which is filled with 0x00
+        buf.clear();
+        buf.putInt( 0 );
+        buf.clear();
+        buf.limit( 4 );
+        Assert.assertEquals( "", buf.getString( decoder ) );
+        Assert.assertEquals( 2, buf.position() );
+        Assert.assertEquals( 4, buf.limit() );
+        
+        buf.position( 0 );
+        Assert.assertEquals( "", buf.getString( 2, decoder ) );
+        Assert.assertEquals( 2, buf.position() );
+        Assert.assertEquals( 4, buf.limit() );
     }
     
     public void testPutString() throws Exception



Mime
View raw message