jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r483415 - /jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/BinaryValue.java
Date Thu, 07 Dec 2006 10:55:04 GMT
Author: tripod
Date: Thu Dec  7 02:55:03 2006
New Revision: 483415

URL: http://svn.apache.org/viewvc?view=rev&rev=483415
Log:
JCR-665 RMI: Property.getValue() fails with EOFException after many reads

Modified:
    jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/BinaryValue.java

Modified: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/BinaryValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/BinaryValue.java?view=diff&rev=483415&r1=483414&r2=483415
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/BinaryValue.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/BinaryValue.java
Thu Dec  7 02:55:03 2006
@@ -185,18 +185,23 @@
      *
      * @param out The <code>ObjectOutputStream</code> to where the binary
      *      data is copied.
-     * @throws IOException If an error occurrs writing the binary data.
+     * @throws IOException If an error occurs writing the binary data.
      */
     private void writeObject(ObjectOutputStream out) throws IOException {
         byte[] buffer = new byte[4096];
         int bytes = 0;
         while ((bytes = stream.read(buffer)) >= 0) {
             // Write a segment of the input stream
-            out.writeInt(bytes);
-            out.write(buffer, 0, bytes);
+            if (bytes > 0) {
+                // just to ensure that no 0 is written
+                out.writeInt(bytes);
+                out.write(buffer, 0, bytes);
+            }
         }
         // Write the end of stream marker
         out.writeInt(0);
+        // close stream
+        stream.close();
     }
 
     /**
@@ -207,7 +212,7 @@
      *
      * @param in The <code>ObjectInputStream</code> from where to get the
      *      binary data.
-     * @throws IOException If an error occurrs reading the binary data.
+     * @throws IOException If an error occurs reading the binary data.
      */
     private void readObject(ObjectInputStream in) throws IOException {
         final File file = File.createTempFile("jcr-value", "bin");



Mime
View raw message