directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r161901 - directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java
Date Tue, 19 Apr 2005 14:49:27 GMT
Author: trustin
Date: Tue Apr 19 07:49:26 2005
New Revision: 161901

URL: http://svn.apache.org/viewcvs?view=rev&rev=161901
Log:
* Fixed: ByteBuffer.getString() throws BufferOverflowException instead of BufferUnderflowException
* Fixed: ByteBuffer.getString() discards mark.

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

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?view=diff&r1=161900&r2=161901
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java Tue Apr 19 07:49:26
2005
@@ -19,6 +19,7 @@
 package org.apache.mina.common;
 
 import java.nio.BufferOverflowException;
+import java.nio.BufferUnderflowException;
 import java.nio.ByteOrder;
 import java.nio.CharBuffer;
 import java.nio.DoubleBuffer;
@@ -914,11 +915,10 @@
         {
             boolean utf16 = decoder.charset().name().startsWith( "UTF-16" );
 
+            int oldPos = buf.position();
             int oldLimit = buf.limit();
             int end;
 
-            buf.mark();
-
             if( !utf16 )
             {
                 while( buf.hasRemaining() )
@@ -960,7 +960,7 @@
                 }
             }
 
-            buf.reset();
+            buf.position( oldPos );
             decoder.reset();
 
             int expectedLength = (int) ( buf.remaining() * decoder.averageCharsPerByte()
);
@@ -1016,16 +1016,15 @@
             }
 
             int i;
+            int oldPos = buf.position();
             int oldLimit = buf.limit();
             int end = buf.position() + fieldSize;
 
             if( oldLimit < end )
             {
-                throw new BufferOverflowException();
+                throw new BufferUnderflowException();
             }
 
-            buf.mark();
-
             if( !utf16 )
             {
                 for( i = 0; i < fieldSize; i ++ )
@@ -1065,7 +1064,7 @@
                 }
             }
 
-            buf.reset();
+            buf.position( oldPos );
             decoder.reset();
 
             int expectedLength = (int) ( buf.remaining() * decoder.averageCharsPerByte()
);



Mime
View raw message