jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpfis...@apache.org
Subject svn commit: r1337188 - in /jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk: client/Client.java server/BoundaryInputStream.java
Date Fri, 11 May 2012 14:42:04 GMT
Author: dpfister
Date: Fri May 11 14:42:03 2012
New Revision: 1337188

URL: http://svn.apache.org/viewvc?rev=1337188&view=rev
Log:
OAK-12 - Implement a test suite for the MicroKernel
- fix ArrayIndexOOB in BoundaryInputStream 
- Client.write(InputStream) should close InputStream

Modified:
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/client/Client.java
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/server/BoundaryInputStream.java

Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/client/Client.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/client/Client.java?rev=1337188&r1=1337187&r2=1337188&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/client/Client.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/client/Client.java
Fri May 11 14:42:03 2012
@@ -352,6 +352,7 @@ public class Client implements MicroKern
             throw toMicroKernelException(e);
         } finally {
             IOUtils.closeQuietly(request);
+            IOUtils.closeQuietly(in);
         }
     }
     

Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/server/BoundaryInputStream.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/server/BoundaryInputStream.java?rev=1337188&r1=1337187&r2=1337188&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/server/BoundaryInputStream.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/server/BoundaryInputStream.java
Fri May 11 14:42:03 2012
@@ -61,8 +61,8 @@ class BoundaryInputStream extends InputS
         this.boundary = ("\r\n" + boundary).getBytes();
 
         // Must be able to unread this many bytes
-        if (size < this.boundary.length + 1) {
-            size = this.boundary.length + 1;
+        if (size < this.boundary.length + 2) {
+            size = this.boundary.length + 2;
         }
         buf = new byte[size];
     }
@@ -104,12 +104,13 @@ class BoundaryInputStream extends InputS
         if (count < 0) {
             eos = true;
         }
+        count += offset;
     }
 
     private int copy(byte[] b, int off, int len) throws IOException {
         int i = 0, j = 0;
 
-        while (i < count && j < len) {
+        while (offset + i < count && j < len) {
             if (boundary[boundaryIndex] == buf[offset + i]) {
                 boundaryIndex++;
                 i++;
@@ -123,7 +124,6 @@ class BoundaryInputStream extends InputS
                     i -= boundaryIndex;
                     if (i < 0) {
                         offset += i;
-                        count += -i;
                         i = 0;
                     }
                     boundaryIndex = 0;



Mime
View raw message