[exo-jcr-commits] exo-jcr SVN: r1637 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Feb 2 11:16:53 EST 2010


Author: areshetnyak
Date: 2010-02-02 11:16:52 -0500 (Tue, 02 Feb 2010)
New Revision: 1637

Modified:
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java
Log:
EXOJCR-451 : The problem with NullPointerException on serialization of PlainChangesLogImpl was fixed.

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java	2010-02-02 16:15:48 UTC (rev 1636)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java	2010-02-02 16:16:52 UTC (rev 1637)
@@ -36,6 +36,9 @@
  */
 public class PlainChangesLogImpl implements Externalizable, PlainChangesLog
 {
+   private static final int NULL_VALUE = -1;
+   
+   private static final int NOT_NULL_VALUE = 1;
 
    private static final long serialVersionUID = 5624550860372364084L;
 
@@ -224,9 +227,17 @@
          out.writeObject(items.get(i));
       }
 
-      buff = pairId.getBytes(Constants.DEFAULT_ENCODING);
-      out.writeInt(buff.length);
-      out.write(buff);
+      if (pairId != null) 
+      {
+         out.writeInt(NOT_NULL_VALUE);
+         buff = pairId.getBytes(Constants.DEFAULT_ENCODING);
+         out.writeInt(buff.length);
+         out.write(buff);
+      }
+      else
+      {
+         out.writeInt(NULL_VALUE);
+      }
    }
 
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
@@ -243,9 +254,12 @@
          add((ItemState)in.readObject());
       }
       
-      buf = new byte[in.readInt()];
-      in.readFully(buf);
-      pairId = new String(buf, Constants.DEFAULT_ENCODING);
+      if (in.readInt() == NOT_NULL_VALUE)
+      {
+         buf = new byte[in.readInt()];
+         in.readFully(buf);
+         pairId = new String(buf, Constants.DEFAULT_ENCODING);
+      }
    }
    // ------------------ [ END ] ------------------
 }



More information about the exo-jcr-commits mailing list