james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1606050 - in /james/mime4j/branches/apache-mime4j-0.7: core/src/main/java/org/apache/james/mime4j/stream/ core/src/test/java/org/apache/james/mime4j/stream/ dom/src/main/java/org/apache/james/mime4j/message/ dom/src/test/java/org/apache/ja...
Date Fri, 27 Jun 2014 12:19:50 GMT
Author: olegk
Date: Fri Jun 27 12:19:50 2014
New Revision: 1606050

URL: http://svn.apache.org/r1606050
Log:
MIME4J-241: inconsistent StringInputStream read zero behavior

Modified:
    james/mime4j/branches/apache-mime4j-0.7/core/src/main/java/org/apache/james/mime4j/stream/RawFieldParser.java
  (contents, props changed)
    james/mime4j/branches/apache-mime4j-0.7/core/src/test/java/org/apache/james/mime4j/stream/RawFieldParserTest.java
  (contents, props changed)
    james/mime4j/branches/apache-mime4j-0.7/dom/src/main/java/org/apache/james/mime4j/message/StringInputStream.java
    james/mime4j/branches/apache-mime4j-0.7/dom/src/test/java/org/apache/james/mime4j/field/address/LenientAddressBuilderTest.java
  (contents, props changed)
    james/mime4j/branches/apache-mime4j-0.7/dom/src/test/java/org/apache/james/mime4j/message/StringInputStreamTest.java

Modified: james/mime4j/branches/apache-mime4j-0.7/core/src/main/java/org/apache/james/mime4j/stream/RawFieldParser.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/apache-mime4j-0.7/core/src/main/java/org/apache/james/mime4j/stream/RawFieldParser.java?rev=1606050&r1=1606049&r2=1606050&view=diff
==============================================================================
    (empty)

Propchange: james/mime4j/branches/apache-mime4j-0.7/core/src/main/java/org/apache/james/mime4j/stream/RawFieldParser.java
            ('svn:executable' removed)

Modified: james/mime4j/branches/apache-mime4j-0.7/core/src/test/java/org/apache/james/mime4j/stream/RawFieldParserTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/apache-mime4j-0.7/core/src/test/java/org/apache/james/mime4j/stream/RawFieldParserTest.java?rev=1606050&r1=1606049&r2=1606050&view=diff
==============================================================================
    (empty)

Propchange: james/mime4j/branches/apache-mime4j-0.7/core/src/test/java/org/apache/james/mime4j/stream/RawFieldParserTest.java
            ('svn:executable' removed)

Modified: james/mime4j/branches/apache-mime4j-0.7/dom/src/main/java/org/apache/james/mime4j/message/StringInputStream.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/apache-mime4j-0.7/dom/src/main/java/org/apache/james/mime4j/message/StringInputStream.java?rev=1606050&r1=1606049&r2=1606050&view=diff
==============================================================================
--- james/mime4j/branches/apache-mime4j-0.7/dom/src/main/java/org/apache/james/mime4j/message/StringInputStream.java
(original)
+++ james/mime4j/branches/apache-mime4j-0.7/dom/src/main/java/org/apache/james/mime4j/message/StringInputStream.java
Fri Jun 27 12:19:50 2014
@@ -87,7 +87,15 @@ class StringInputStream extends InputStr
                 }
             }
         }
-        return bytesRead == 0 && !this.cbuf.hasRemaining() ? -1 : bytesRead;
+        if (bytesRead > 0) {
+            return bytesRead;
+        } else {
+            if (!this.bbuf.hasRemaining() && !this.cbuf.hasRemaining()) {
+                return -1;
+            } else {
+                return bytesRead;
+            }
+        }
     }
 
     @Override

Modified: james/mime4j/branches/apache-mime4j-0.7/dom/src/test/java/org/apache/james/mime4j/field/address/LenientAddressBuilderTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/apache-mime4j-0.7/dom/src/test/java/org/apache/james/mime4j/field/address/LenientAddressBuilderTest.java?rev=1606050&r1=1606049&r2=1606050&view=diff
==============================================================================
    (empty)

Propchange: james/mime4j/branches/apache-mime4j-0.7/dom/src/test/java/org/apache/james/mime4j/field/address/LenientAddressBuilderTest.java
            ('svn:executable' removed)

Modified: james/mime4j/branches/apache-mime4j-0.7/dom/src/test/java/org/apache/james/mime4j/message/StringInputStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/apache-mime4j-0.7/dom/src/test/java/org/apache/james/mime4j/message/StringInputStreamTest.java?rev=1606050&r1=1606049&r2=1606050&view=diff
==============================================================================
--- james/mime4j/branches/apache-mime4j-0.7/dom/src/test/java/org/apache/james/mime4j/message/StringInputStreamTest.java
(original)
+++ james/mime4j/branches/apache-mime4j-0.7/dom/src/test/java/org/apache/james/mime4j/message/StringInputStreamTest.java
Fri Jun 27 12:19:50 2014
@@ -102,6 +102,17 @@ public class StringInputStreamTest exten
         assertEquals(0, r.read(bytes, 0, 0));
     }
 
+    public void testReadZero2() throws Exception {
+        InputStream r = new StringInputStream("test", CharsetUtil.UTF_8);
+        byte[] bytes = new byte[30];
+        assertEquals(2, r.read(bytes, 0, 2));
+        assertEquals(0, r.read(bytes, 2, 0));
+        assertEquals(0, r.read(bytes, 2, 0));
+        assertEquals(2, r.read(bytes, 2, 2));
+        assertEquals(-1, r.read(bytes, 4, 0));
+        assertEquals(-1, r.read(bytes, 4, 2));
+    }
+
     public void testSkip() throws Exception {
         InputStream r = new StringInputStream("test", CharsetUtil.UTF_8);
         r.skip(1);



Mime
View raw message