commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject svn commit: r1746612 - in /commons/proper/io/trunk/src: main/java/org/apache/commons/io/input/BoundedReader.java test/java/org/apache/commons/io/input/BoundedReaderTest.java
Date Thu, 02 Jun 2016 18:15:04 GMT
Author: krosenvold
Date: Thu Jun  2 18:15:04 2016
New Revision: 1746612

URL: http://svn.apache.org/viewvc?rev=1746612&view=rev
Log:
Update BoundedReader.java
https://docs.oracle.com/javase/8/docs/api/java/io/Reader.html
Add read bytes EOF test

Patch by zhanhb <zhanhb88@gmail.com>, applied unmodified

Modified:
    commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/BoundedReader.java
    commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BoundedReaderTest.java

Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/BoundedReader.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/BoundedReader.java?rev=1746612&r1=1746611&r2=1746612&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/BoundedReader.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/BoundedReader.java Thu
Jun  2 18:15:04 2016
@@ -139,7 +139,7 @@ public class BoundedReader
         for ( int i = 0; i < len; i++ ) {
             c = read();
             if ( c == -1 ) {
-                return i;
+                return i == 0 ? -1 : i;
             }
             cbuf[off + i] = (char) c;
         }

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BoundedReaderTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BoundedReaderTest.java?rev=1746612&r1=1746611&r2=1746612&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BoundedReaderTest.java
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BoundedReaderTest.java
Thu Jun  2 18:15:04 2016
@@ -181,4 +181,12 @@ public class BoundedReaderTest
         mr.close();
         assertTrue( closed.get() );
     }
-}
\ No newline at end of file
+
+    @Test(timeout = 5000)
+    public void testReadBytesEOF() throws IOException {
+        BoundedReader mr = new BoundedReader( sr, 3 );
+        BufferedReader br = new BufferedReader( mr );
+        br.readLine();
+        br.readLine();
+    }
+}



Mime
View raw message