Author: rgoers
Date: Sun Sep 25 22:52:08 2011
New Revision: 1175615

URL: http://svn.apache.org/viewvc?rev=1175615&view=rev
Log:
Fix VFS-355 - The read method of RamFileRandomAccessContent's input stream does 
not return -1 at eof.

Modified:
    
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileRandomAccessContent.java
    commons/proper/vfs/trunk/src/changes/changes.xml

Modified: 
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileRandomAccessContent.java
URL: 
http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileRandomAccessContent.java?rev=1175615&r1=1175614&r2=1175615&view=diff
==============================================================================
--- 
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileRandomAccessContent.java
 (original)
+++ 
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileRandomAccessContent.java
 Sun Sep 25 22:52:08 2011
@@ -121,8 +121,12 @@ public class RamFileRandomAccessContent 
             @Override
             public int read(byte[] b, int off, int len) throws IOException
             {
-                int retLen = Math.min(len, getLeftBytes());
-                RamFileRandomAccessContent.this.readFully(b, off, retLen);
+                int retLen = -1;
+                final int left = getLeftBytes();
+                if (left > 0) {
+                    retLen = Math.min(len, left);
+                    RamFileRandomAccessContent.this.readFully(b, off, retLen);
+                }
                 return retLen;
             }
 

Modified: commons/proper/vfs/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/vfs/trunk/src/changes/changes.xml?rev=1175615&r1=1175614&r2=1175615&view=diff
==============================================================================
--- commons/proper/vfs/trunk/src/changes/changes.xml (original)
+++ commons/proper/vfs/trunk/src/changes/changes.xml Sun Sep 25 22:52:08 2011
@@ -23,6 +23,9 @@
 
   <body>
     <release version="2.1" date="TBD" description="">
+      <action issue="VFS-355" dev="rgoers" type="fix" due-to="Miroslav 
Pokorny">
+        The read method of RamFileRandomAccessContent's input stream does not 
return -1 at eof.
+      </action>
       <action issue="VFS-356" dev="rgoers" type="fix">
         Throw an IOException if an attempt is made to seek to a position 
before the start of the file.
       </action>


Reply via email to