[exo-jcr-commits] exo-jcr SVN: r1494 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Jan 19 20:22:18 EST 2010


Author: pnedonosko
Date: 2010-01-19 20:22:17 -0500 (Tue, 19 Jan 2010)
New Revision: 1494

Modified:
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java
Log:
EXOJCR-404 empty constructors and serialization errors on null file

Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java	2010-01-20 00:45:17 UTC (rev 1493)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java	2010-01-20 01:22:17 UTC (rev 1494)
@@ -53,7 +53,7 @@
     * The serialVersionUID.
     */
    private static final long serialVersionUID = -8183328056670315388L;
-   
+
    protected File file;
 
    protected FileChannel channel;
@@ -63,9 +63,8 @@
     */
    public FilePersistedValueData()
    {
-      super();
    }
-   
+
    /**
     * FilePersistedValueData  constructor.
     * @param orderNumber int
@@ -239,10 +238,18 @@
       orderNumber = in.readInt();
 
       // read canonical file path
-      byte[] buf = new byte[in.readInt()];
-      in.readFully(buf);
-      
-      file = new File(new String(buf, "UTF-8"));
+      int size = in.readInt();
+      if (size >= 0)
+      {
+         byte[] buf = new byte[size];
+         in.readFully(buf);
+
+         file = new File(new String(buf, "UTF-8"));
+      }
+      else
+      {
+         throw new IOException("Persisted ValueData with null file found");
+      }
    }
 
    /**
@@ -251,10 +258,17 @@
    public void writeExternal(ObjectOutput out) throws IOException
    {
       out.writeInt(orderNumber);
-      
-      // write canonical file path 
-      byte[] buf = file.getCanonicalPath().getBytes("UTF-8");
-      out.writeInt(buf.length);
-      out.write(buf);
+
+      // write canonical file path
+      if (file != null)
+      {
+         byte[] buf = file.getCanonicalPath().getBytes("UTF-8");
+         out.writeInt(buf.length);
+         out.write(buf);
+      }
+      else
+      {
+         throw new IOException("Persisted ValueData with null file found");
+      }
    }
 }

Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java	2010-01-20 00:45:17 UTC (rev 1493)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java	2010-01-20 01:22:17 UTC (rev 1494)
@@ -96,6 +96,13 @@
    }
 
    /**
+    * StreamPersistedValueData empty constructor for serialization.
+    */
+   public StreamPersistedValueData()
+   {
+   }
+
+   /**
     * Return original data stream or null. <br/>
     * For persistent transformation from non-spooled TransientValueData to persistent layer.<br/>
     * WARN: after the stream will be consumed it will not contains data anymore.  



More information about the exo-jcr-commits mailing list