You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by re...@apache.org on 2017/02/23 18:30:09 UTC

svn commit: r1784186 - in /jackrabbit/oak/branches/1.4: ./ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/ oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/ oak-core/src/test/java/org/apache/jackrabbit/oak/plugin...

Author: reschke
Date: Thu Feb 23 18:30:09 2017
New Revision: 1784186

URL: http://svn.apache.org/viewvc?rev=1784186&view=rev
Log:
OAK-5751: RDBDocumentStore: properly handle null values for system properties (ported to 1.4)

Modified:
    jackrabbit/oak/branches/1.4/   (props changed)
    jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializer.java
    jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
    jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStoreJDBC.java
    jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBExport.java
    jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBRow.java
    jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java
    jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializerTest.java

Propchange: jackrabbit/oak/branches/1.4/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 23 18:30:09 2017
@@ -1,3 +1,3 @@
 /jackrabbit/oak/branches/1.0:1665962
-/jackrabbit/oak/trunk:1733615,1733875,1733913,1733929,1734230,1734254,1734279,1734941,1735052,1735081,1735109,1735141,1735267,1735405,1735484,1735549,1735564,1735588,1735622,1735638,1735919,1735983,1736176,1737309-1737310,1737334,1737349,1737998,1738004,1738136,1738138,1738207,1738234,1738252,1738775,1738795,1738833,1738950,1738957,1738963,1739712,1739760,1739867,1739894,1739959-1739960,1740114,1740116,1740250,1740333,1740349,1740360,1740625-1740626,1740774,1740837,1740879,1740971,1741016,1741032,1741339,1741343,1742077,1742117,1742125,1742363,1742520,1742888,1742916,1743097,1743172,1743343,1743674,1744265,1744292,1744589,1744670,1744672,1744959,1745038,1745127,1745197,1745336,1745368,1746086,1746117,1746342,1746345,1746408,1746696,1746981,1747198,1747200,1747341-1747342,1747380,1747387,1747406,1747492,1747512,1747654,1748505,1748553,1748722,1748870,1749275,1749350,1749424,1749443,1749464,1749475,1749645,1749662,1749815,1749872,1749875,1749899,1750052,1750076-1750077,1750287,1750457
 ,1750462,1750465,1750495,1750626,1750809,1750886-1750887,1751396,1751410,1751419,1751445-1751446,1751478,1751748,1751753,1751755,1751871,1752198,1752202,1752259,1752273-1752274,1752283,1752292,1752438,1752447-1752448,1752508,1752596,1752616,1752659,1752672,1753262,1753331-1753332,1753335-1753336,1753355,1753444,1754117,1754239,1755157,1755191,1756520,1756580,1757119,1757166,1758213,1758713,1759433,1759795,1759826,1760326,1760340,1760373,1760387,1760486,1760492,1760494,1760661-1760662,1761412,1761444,1761571,1761762,1761787,1761876,1762453,1762612,1762632,1762635,1763347,1763355-1763356,1763378,1763465,1763735,1764678,1764705,1764814,1764898,1765817,1765983,1766071,1766390,1766423,1766496,1766519,1766554,1766644,1767025,1767265,1767704,1768446,1768637,1769078,1770694,1770982,1771022,1771093,1771098,1771739,1771852,1771870,1771902,1772155,1772162,1772228,1772593,1772768,1773190,1774497,1775474,1775622,1775628,1775757,1778423,1778968,1779478,1780388,1780538,1780543,1781068,1781075,1781
 386,1781846,1781907,1783066,1783089,1783104-1783105,1783619,1783855,1784130
+/jackrabbit/oak/trunk:1733615,1733875,1733913,1733929,1734230,1734254,1734279,1734941,1735052,1735081,1735109,1735141,1735267,1735405,1735484,1735549,1735564,1735588,1735622,1735638,1735919,1735983,1736176,1737309-1737310,1737334,1737349,1737998,1738004,1738136,1738138,1738207,1738234,1738252,1738775,1738795,1738833,1738950,1738957,1738963,1739712,1739760,1739867,1739894,1739959-1739960,1740114,1740116,1740250,1740333,1740349,1740360,1740625-1740626,1740774,1740837,1740879,1740971,1741016,1741032,1741339,1741343,1742077,1742117,1742125,1742363,1742520,1742888,1742916,1743097,1743172,1743343,1743674,1744265,1744292,1744589,1744670,1744672,1744959,1745038,1745127,1745197,1745336,1745368,1746086,1746117,1746342,1746345,1746408,1746696,1746981,1747198,1747200,1747341-1747342,1747380,1747387,1747406,1747492,1747512,1747654,1748505,1748553,1748722,1748870,1749275,1749350,1749424,1749443,1749464,1749475,1749645,1749662,1749815,1749872,1749875,1749899,1750052,1750076-1750077,1750287,1750457
 ,1750462,1750465,1750495,1750626,1750809,1750886-1750887,1751396,1751410,1751419,1751445-1751446,1751478,1751748,1751753,1751755,1751871,1752198,1752202,1752259,1752273-1752274,1752283,1752292,1752438,1752447-1752448,1752508,1752596,1752616,1752659,1752672,1753262,1753331-1753332,1753335-1753336,1753355,1753444,1754117,1754239,1755157,1755191,1756520,1756580,1757119,1757166,1758213,1758713,1759433,1759795,1759826,1760326,1760340,1760373,1760387,1760486,1760492,1760494,1760661-1760662,1761412,1761444,1761571,1761762,1761787,1761876,1762453,1762612,1762632,1762635,1763347,1763355-1763356,1763378,1763465,1763735,1764678,1764705,1764814,1764898,1765817,1765983,1766071,1766390,1766423,1766496,1766519,1766554,1766644,1767025,1767265,1767704,1768446,1768637,1769078,1770694,1770982,1771022,1771093,1771098,1771739,1771852,1771870,1771902,1772155,1772162,1772228,1772593,1772768,1773190,1774497,1775474,1775622,1775628,1775757,1778423,1778968,1779478,1780388,1780538,1780543,1781068,1781075,1781
 386,1781846,1781907,1783066,1783089,1783104-1783105,1783619,1783855,1784023,1784130
 /jackrabbit/trunk:1345480

Modified: jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializer.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializer.java?rev=1784186&r1=1784185&r2=1784186&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializer.java (original)
+++ jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializer.java Thu Feb 23 18:30:09 2017
@@ -160,11 +160,11 @@ public class RDBDocumentSerializer {
         if (RDBDocumentStore.USECMODCOUNT && row.getCollisionsModcount() != RDBRow.LONG_UNSET) {
             doc.put(CMODCOUNT, row.getCollisionsModcount());
         }
-        if (row.hasBinaryProperties()) {
-            doc.put(HASBINARY, NodeDocument.HAS_BINARY_VAL);
+        if (row.hasBinaryProperties() != null) {
+            doc.put(HASBINARY, row.hasBinaryProperties().longValue());
         }
-        if (row.deletedOnce()) {
-            doc.put(DELETEDONCE, Boolean.TRUE);
+        if (row.deletedOnce() != null) {
+            doc.put(DELETEDONCE, row.deletedOnce().booleanValue());
         }
 
         byte[] bdata = row.getBdata();

Modified: jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java?rev=1784186&r1=1784185&r2=1784186&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java (original)
+++ jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java Thu Feb 23 18:30:09 2017
@@ -1572,10 +1572,8 @@ public class RDBDocumentStore implements
         String data = null;
         try {
             connection = this.ch.getRWConnection();
-            Number flagB = (Number) document.get(NodeDocument.HAS_BINARY_FLAG);
-            Boolean hasBinary = flagB != null && flagB.intValue() == NodeDocument.HAS_BINARY_VAL;
-            Boolean flagD = (Boolean) document.get(NodeDocument.DELETED_ONCE);
-            Boolean deletedOnce = flagD != null && flagD.booleanValue();
+            Number hasBinary = (Number) document.get(NodeDocument.HAS_BINARY_FLAG);
+            Boolean deletedOnce = (Boolean) document.get(NodeDocument.DELETED_ONCE);
             Long modcount = (Long) document.get(MODCOUNT);
             Long cmodcount = (Long) document.get(COLLISIONSMODCOUNT);
             boolean success = false;

Modified: jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStoreJDBC.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStoreJDBC.java?rev=1784186&r1=1784185&r2=1784186&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStoreJDBC.java (original)
+++ jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStoreJDBC.java Thu Feb 23 18:30:09 2017
@@ -84,7 +84,7 @@ public class RDBDocumentStoreJDBC {
     }
 
     public boolean appendingUpdate(Connection connection, RDBTableMetaData tmd, String id, Long modified,
-            boolean setModifiedConditionally, Boolean hasBinary, Boolean deletedOnce, Long modcount, Long cmodcount,
+            boolean setModifiedConditionally, Number hasBinary, Boolean deletedOnce, Long modcount, Long cmodcount,
             Long oldmodcount, String appendData) throws SQLException {
         String appendDataWithComma = "," + appendData;
         PreparedStatementComponent stringAppend = this.dbInfo.getConcatQuery(appendDataWithComma, tmd.getDataLimitInOctets());
@@ -104,8 +104,8 @@ public class RDBDocumentStoreJDBC {
             if (setModifiedConditionally) {
                 stmt.setObject(si++, modified, Types.BIGINT);
             }
-            stmt.setObject(si++, hasBinary ? 1 : 0, Types.SMALLINT);
-            stmt.setObject(si++, deletedOnce ? 1 : 0, Types.SMALLINT);
+            stmt.setObject(si++, hasBinaryAsNullOrInteger(hasBinary), Types.SMALLINT);
+            stmt.setObject(si++, deletedOnceAsNullOrInteger(deletedOnce), Types.SMALLINT);
             stmt.setObject(si++, modcount, Types.BIGINT);
             stmt.setObject(si++, cmodcount == null ? Long.valueOf(0) : cmodcount, Types.BIGINT);
             stmt.setObject(si++, appendDataWithComma.length(), Types.BIGINT);
@@ -282,9 +282,8 @@ public class RDBDocumentStoreJDBC {
                 int si = 1;
                 setIdInStatement(tmd, stmt, si++, id);
                 stmt.setObject(si++, document.get(MODIFIED), Types.BIGINT);
-                stmt.setObject(si++, (hasBinary != null && hasBinary.intValue() == NodeDocument.HAS_BINARY_VAL) ? 1 : 0,
-                        Types.SMALLINT);
-                stmt.setObject(si++, (deletedOnce != null && deletedOnce) ? 1 : 0, Types.SMALLINT);
+                stmt.setObject(si++, hasBinaryAsNullOrInteger(hasBinary), Types.SMALLINT);
+                stmt.setObject(si++, deletedOnceAsNullOrInteger(deletedOnce), Types.SMALLINT);
                 stmt.setObject(si++, document.get(MODCOUNT), Types.BIGINT);
                 stmt.setObject(si++, cmodcount == null ? Long.valueOf(0) : cmodcount, Types.BIGINT);
                 stmt.setObject(si++, data.length(), Types.BIGINT);
@@ -361,9 +360,8 @@ public class RDBDocumentStoreJDBC {
 
                 int si = 1;
                 stmt.setObject(si++, document.get(MODIFIED), Types.BIGINT);
-                stmt.setObject(si++, (hasBinary != null && hasBinary.intValue() == NodeDocument.HAS_BINARY_VAL) ? 1 : 0,
-                        Types.SMALLINT);
-                stmt.setObject(si++, (deletedOnce != null && deletedOnce) ? 1 : 0, Types.SMALLINT);
+                stmt.setObject(si++, hasBinaryAsNullOrInteger(hasBinary), Types.SMALLINT);
+                stmt.setObject(si++, deletedOnceAsNullOrInteger(deletedOnce), Types.SMALLINT);
                 stmt.setObject(si++, modcount, Types.BIGINT);
                 stmt.setObject(si++, cmodcount == null ? Long.valueOf(0) : cmodcount, Types.BIGINT);
                 stmt.setObject(si++, data.length(), Types.BIGINT);
@@ -544,11 +542,11 @@ public class RDBDocumentStoreJDBC {
                 long modified = readLongFromResultSet(rs, 2);
                 long modcount = readLongFromResultSet(rs, 3);
                 long cmodcount = readLongFromResultSet(rs, 4);
-                long hasBinary = rs.getLong(5);
-                long deletedOnce = rs.getLong(6);
+                Long hasBinary = readLongOrNullFromResultSet(rs, 5);
+                Boolean deletedOnce = readBooleanOrNullFromResultSet(rs, 6);
                 String data = rs.getString(7);
                 byte[] bdata = rs.getBytes(8);
-                result.add(new RDBRow(id, hasBinary == 1, deletedOnce == 1, modified, modcount, cmodcount, data, bdata));
+                result.add(new RDBRow(id, hasBinary, deletedOnce, modified, modcount, cmodcount, data, bdata));
                 dataTotal += data.length();
                 bdataTotal += bdata == null ? 0 : bdata.length;
             }
@@ -599,11 +597,11 @@ public class RDBDocumentStoreJDBC {
                     long modified = readLongFromResultSet(rs, col++);
                     long modcount = readLongFromResultSet(rs, col++);
                     long cmodcount = readLongFromResultSet(rs, col++);
-                    long hasBinary = rs.getLong(col++);
-                    long deletedOnce = rs.getLong(col++);
+                    Long hasBinary = readLongOrNullFromResultSet(rs, col++);
+                    Boolean deletedOnce = readBooleanOrNullFromResultSet(rs, col++);
                     String data = rs.getString(col++);
                     byte[] bdata = rs.getBytes(col++);
-                    RDBRow row = new RDBRow(id, hasBinary == 1, deletedOnce == 1, modified, modcount, cmodcount, data, bdata);
+                    RDBRow row = new RDBRow(id, hasBinary, deletedOnce, modified, modcount, cmodcount, data, bdata);
                     rows.add(row);
                 }
             } catch (SQLException ex) {
@@ -663,11 +661,11 @@ public class RDBDocumentStoreJDBC {
                 long modified = readLongFromResultSet(rs, 1);
                 long modcount = readLongFromResultSet(rs, 2);
                 long cmodcount = readLongFromResultSet(rs, 3);
-                long hasBinary = rs.getLong(4);
-                long deletedOnce = rs.getLong(5);
+                Long hasBinary = readLongOrNullFromResultSet(rs, 4);
+                Boolean deletedOnce = readBooleanOrNullFromResultSet(rs, 5);
                 String data = rs.getString(6);
                 byte[] bdata = rs.getBytes(7);
-                return new RDBRow(id, hasBinary == 1, deletedOnce == 1, modified, modcount, cmodcount, data, bdata);
+                return new RDBRow(id, hasBinary, deletedOnce, modified, modcount, cmodcount, data, bdata);
             } else {
                 return null;
             }
@@ -691,7 +689,7 @@ public class RDBDocumentStoreJDBC {
         }
     }
 
-    public boolean update(Connection connection, RDBTableMetaData tmd, String id, Long modified, Boolean hasBinary,
+    public boolean update(Connection connection, RDBTableMetaData tmd, String id, Long modified, Number hasBinary,
             Boolean deletedOnce, Long modcount, Long cmodcount, Long oldmodcount, String data) throws SQLException {
 
         StringBuilder t = new StringBuilder();
@@ -705,8 +703,8 @@ public class RDBDocumentStoreJDBC {
         try {
             int si = 1;
             stmt.setObject(si++, modified, Types.BIGINT);
-            stmt.setObject(si++, hasBinary ? 1 : 0, Types.SMALLINT);
-            stmt.setObject(si++, deletedOnce ? 1 : 0, Types.SMALLINT);
+            stmt.setObject(si++, hasBinaryAsNullOrInteger(hasBinary), Types.SMALLINT);
+            stmt.setObject(si++, deletedOnceAsNullOrInteger(deletedOnce), Types.SMALLINT);
             stmt.setObject(si++, modcount, Types.BIGINT);
             stmt.setObject(si++, cmodcount == null ? Long.valueOf(0) : cmodcount, Types.BIGINT);
             stmt.setObject(si++, data.length(), Types.BIGINT);
@@ -766,6 +764,31 @@ public class RDBDocumentStoreJDBC {
         return res.wasNull() ? RDBRow.LONG_UNSET : v;
     }
 
+    @CheckForNull
+    private static Boolean readBooleanOrNullFromResultSet(ResultSet res, int index) throws SQLException {
+        long v = res.getLong(index);
+        return res.wasNull() ? null : Boolean.valueOf(v != 0);
+    }
+
+    @CheckForNull
+    private static Long readLongOrNullFromResultSet(ResultSet res, int index) throws SQLException {
+        long v = res.getLong(index);
+        return res.wasNull() ? null : Long.valueOf(v);
+    }
+
+    private static final Integer INT_FALSE = 0;
+    private static final Integer INT_TRUE = 1;
+    
+    @CheckForNull
+    private static Integer deletedOnceAsNullOrInteger(Boolean b) {
+        return b == null ? null : (b.booleanValue() ? INT_TRUE : INT_FALSE);
+    }
+
+    @CheckForNull
+    private static Integer hasBinaryAsNullOrInteger(Number n) {
+        return n == null ? null : (n.longValue() == 1 ? INT_TRUE : INT_FALSE);
+    }
+
     private static <T extends Document> List<T> sortDocuments(Collection<T> documents) {
         List<T> result = new ArrayList<T>(documents);
         Collections.sort(result, new Comparator<T>() {

Modified: jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBExport.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBExport.java?rev=1784186&r1=1784185&r2=1784186&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBExport.java (original)
+++ jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBExport.java Thu Feb 23 18:30:09 2017
@@ -42,6 +42,7 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 
+import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 
 import org.apache.commons.io.IOUtils;
@@ -215,7 +216,7 @@ public class RDBExport {
                 IOUtils.closeQuietly(is);
             }
             try {
-                RDBRow row = new RDBRow(id, "1".equals(shasbinary), "1".equals(sdeletedonce),
+                RDBRow row = new RDBRow(id, "1".equals(shasbinary) ? 1L : 0L, "1".equals(sdeletedonce),
                         smodified.length() == 0 ? 0 : Long.parseLong(smodified), Long.parseLong(smodcount),
                         Long.parseLong(scmodcount), sdata, bytes);
                 StringBuilder fulljson = dumpRow(ser, id, row);
@@ -314,12 +315,12 @@ public class RDBExport {
             long modified = rs.getLong("MODIFIED");
             long modcount = rs.getLong("MODCOUNT");
             long cmodcount = rs.getLong("CMODCOUNT");
-            long hasBinary = rs.getLong("HASBINARY");
-            long deletedOnce = rs.getLong("DELETEDONCE");
+            Long hasBinary = readLongOrNullFromResultSet(rs, "HASBINARY");
+            Boolean deletedOnce = readBooleanOrNullFromResultSet(rs, "DELETEDONCE");
             String data = rs.getString("DATA");
             byte[] bdata = rs.getBytes("BDATA");
 
-            RDBRow row = new RDBRow(id, hasBinary == 1, deletedOnce == 1, modified, modcount, cmodcount, data, bdata);
+            RDBRow row = new RDBRow(id, hasBinary, deletedOnce, modified, modcount, cmodcount, data, bdata);
             StringBuilder fulljson = dumpRow(ser, id, row);
             if (format == Format.CSV) {
                 out.println(asCSV(fieldNames, fulljson));
@@ -341,6 +342,18 @@ public class RDBExport {
         c.close();
     }
 
+    @CheckForNull
+    private static Boolean readBooleanOrNullFromResultSet(ResultSet res, String field) throws SQLException {
+        long v = res.getLong(field);
+        return res.wasNull() ? null : Boolean.valueOf(v != 0);
+    }
+
+    @CheckForNull
+    private static Long readLongOrNullFromResultSet(ResultSet res, String field) throws SQLException {
+        long v = res.getLong(field);
+        return res.wasNull() ? null : Long.valueOf(v);
+    }
+
     @Nonnull
     private static StringBuilder dumpRow(RDBDocumentSerializer ser, String id, RDBRow row) {
         NodeDocument doc = ser.fromRow(Collection.NODES, row);

Modified: jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBRow.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBRow.java?rev=1784186&r1=1784185&r2=1784186&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBRow.java (original)
+++ jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBRow.java Thu Feb 23 18:30:09 2017
@@ -31,12 +31,13 @@ public class RDBRow {
     public static final long LONG_UNSET = Long.MIN_VALUE;
 
     private final String id;
-    private final boolean hasBinaryProperties, deletedOnce;
+    private final Long hasBinaryProperties;
+    private final Boolean deletedOnce;
     private final long modified, modcount, cmodcount;
     private final String data;
     private final byte[] bdata;
 
-    public RDBRow(String id, boolean hasBinaryProperties, boolean deletedOnce, Long modified, Long modcount, Long cmodcount, String data, byte[] bdata) {
+    public RDBRow(String id, Long hasBinaryProperties, Boolean deletedOnce, Long modified, Long modcount, Long cmodcount, String data, byte[] bdata) {
         this.id = id;
         this.hasBinaryProperties = hasBinaryProperties;
         this.deletedOnce = deletedOnce;
@@ -52,11 +53,13 @@ public class RDBRow {
         return id;
     }
 
-    public boolean hasBinaryProperties() {
+    @CheckForNull
+    public Long hasBinaryProperties() {
         return hasBinaryProperties;
     }
 
-    public boolean deletedOnce() {
+    @CheckForNull
+    public Boolean deletedOnce() {
         return deletedOnce;
     }
 

Modified: jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java?rev=1784186&r1=1784185&r2=1784186&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java (original)
+++ jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java Thu Feb 23 18:30:09 2017
@@ -90,6 +90,51 @@ public class BasicDocumentStoreTest exte
         removeMe.add(id);
     }
 
+    public void testValuesForSystemProps() {
+        String id = this.getClass().getName() + ".testValuesForSystemProps";
+
+        // remove if present
+        NodeDocument nd = super.ds.find(Collection.NODES, id);
+        if (nd != null) {
+            super.ds.remove(Collection.NODES, id);
+        }
+        removeMe.add(id);
+
+        // add
+        UpdateOp up = new UpdateOp(id, true);
+        assertTrue(super.ds.create(Collection.NODES, Collections.singletonList(up)));
+
+        super.ds.invalidateCache();
+        nd = super.ds.find(Collection.NODES, id, 0);
+        assertNull(nd.get(NodeDocument.DELETED_ONCE));
+        assertNull(nd.get(NodeDocument.HAS_BINARY_FLAG));
+        assertFalse(nd.wasDeletedOnce());
+        assertFalse(nd.hasBinary());
+        
+        up = new UpdateOp(id, false);
+        up.set(NodeDocument.DELETED_ONCE, true);
+        super.ds.findAndUpdate(Collection.NODES, up);
+        
+        super.ds.invalidateCache();
+        nd = super.ds.find(Collection.NODES, id, 0);
+        assertEquals(true, nd.get(NodeDocument.DELETED_ONCE));
+        assertNull(nd.get(NodeDocument.HAS_BINARY_FLAG));
+        assertTrue(nd.wasDeletedOnce());
+        assertFalse(nd.hasBinary());
+
+        up = new UpdateOp(id, false);
+        up.set(NodeDocument.DELETED_ONCE, false);
+        up.set(NodeDocument.HAS_BINARY_FLAG, NodeDocument.HAS_BINARY_VAL);
+        super.ds.findAndUpdate(Collection.NODES, up);
+        
+        super.ds.invalidateCache();
+        nd = super.ds.find(Collection.NODES, id, 0);
+        assertEquals(false, nd.get(NodeDocument.DELETED_ONCE));
+        assertEquals(NodeDocument.HAS_BINARY_VAL, nd.get(NodeDocument.HAS_BINARY_FLAG));
+        assertFalse(nd.wasDeletedOnce());
+        assertTrue(nd.hasBinary());
+    }
+
     @Test
     public void testConflictingId() {
         String id = this.getClass().getName() + ".testConflictingId";

Modified: jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializerTest.java?rev=1784186&r1=1784185&r2=1784186&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializerTest.java (original)
+++ jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializerTest.java Thu Feb 23 18:30:09 2017
@@ -56,7 +56,7 @@ public class RDBDocumentSerializerTest {
 
     @Test
     public void testSimpleString() {
-        RDBRow row = new RDBRow("_foo", true, true, 1l, 2l, 3l, "{}", null);
+        RDBRow row = new RDBRow("_foo", 1L, true, 1l, 2l, 3l, "{}", null);
         NodeDocument doc = this.ser.fromRow(Collection.NODES, row);
         assertEquals("_foo", doc.getId());
         assertEquals(true, doc.hasBinary());
@@ -65,8 +65,20 @@ public class RDBDocumentSerializerTest {
     }
 
     @Test
+    public void testNoSysprops() {
+        RDBRow row = new RDBRow("_foo", null, null, 1l, 2l, 3l, "{}", null);
+        NodeDocument doc = this.ser.fromRow(Collection.NODES, row);
+        assertEquals("_foo", doc.getId());
+        assertEquals(false, doc.hasBinary());
+        assertNull(null, doc.get(NodeDocument.HAS_BINARY_FLAG));
+        assertEquals(false, doc.wasDeletedOnce());
+        assertNull(null, doc.get(NodeDocument.DELETED_ONCE));
+        assertEquals(2L, doc.getModCount().longValue());
+    }
+
+    @Test
     public void testSimpleBlob() throws UnsupportedEncodingException {
-        RDBRow row = new RDBRow("_foo", false, false, 1l, 2l, 3l, "\"blob\"", "{}".getBytes("UTF-8"));
+        RDBRow row = new RDBRow("_foo", 0L, false, 1l, 2l, 3l, "\"blob\"", "{}".getBytes("UTF-8"));
         NodeDocument doc = this.ser.fromRow(Collection.NODES, row);
         assertEquals("_foo", doc.getId());
         assertEquals(false, doc.hasBinary());
@@ -75,7 +87,7 @@ public class RDBDocumentSerializerTest {
 
     @Test
     public void testSimpleBlob2() throws UnsupportedEncodingException {
-        RDBRow row = new RDBRow("_foo", false, false, 1l, 2l, 3l, "\"blob\"",
+        RDBRow row = new RDBRow("_foo", 0L, false, 1l, 2l, 3l, "\"blob\"",
                 "{\"s\":\"string\", \"b\":true, \"i\":1}".getBytes("UTF-8"));
         NodeDocument doc = this.ser.fromRow(Collection.NODES, row);
         assertEquals("_foo", doc.getId());
@@ -89,7 +101,7 @@ public class RDBDocumentSerializerTest {
     @Test
     public void testSimpleBoth() throws UnsupportedEncodingException {
         try {
-            RDBRow row = new RDBRow("_foo", true, false, 1l, 2l, 3l, "{}", "{}".getBytes("UTF-8"));
+            RDBRow row = new RDBRow("_foo", 1L, false, 1l, 2l, 3l, "{}", "{}".getBytes("UTF-8"));
             this.ser.fromRow(Collection.NODES, row);
             fail("should fail");
         } catch (DocumentStoreException expected) {
@@ -98,7 +110,7 @@ public class RDBDocumentSerializerTest {
 
     @Test
     public void testBlobAndDiff() throws UnsupportedEncodingException {
-        RDBRow row = new RDBRow("_foo", true, false, 1l, 2l, 3l,
+        RDBRow row = new RDBRow("_foo", 1L, false, 1l, 2l, 3l,
                 "\"blob\", [[\"=\", \"foo\", \"bar\"],[\"M\", \"m1\", 1],[\"M\", \"m2\", 3]]",
                 "{\"m1\":2, \"m2\":2}".getBytes("UTF-8"));
         NodeDocument doc = this.ser.fromRow(Collection.NODES, row);
@@ -110,7 +122,7 @@ public class RDBDocumentSerializerTest {
     @Test
     public void testBlobAndDiffBorked() throws UnsupportedEncodingException {
         try {
-            RDBRow row = new RDBRow("_foo", true, false, 1l, 2l, 3l, "[[\"\", \"\", \"\"]]", "{}".getBytes("UTF-8"));
+            RDBRow row = new RDBRow("_foo", 1L, false, 1l, 2l, 3l, "[[\"\", \"\", \"\"]]", "{}".getBytes("UTF-8"));
             this.ser.fromRow(Collection.NODES, row);
             fail("should fail");
         } catch (DocumentStoreException expected) {
@@ -119,7 +131,7 @@ public class RDBDocumentSerializerTest {
 
     @Test
     public void testNullModified() throws UnsupportedEncodingException {
-        RDBRow row = new RDBRow("_foo", true, true, null, 2l, 3l, "{}", null);
+        RDBRow row = new RDBRow("_foo", 1L, true, null, 2l, 3l, "{}", null);
         NodeDocument doc = this.ser.fromRow(Collection.NODES, row);
         assertNull(doc.getModified());
     }
@@ -127,7 +139,7 @@ public class RDBDocumentSerializerTest {
     @Test
     public void testBrokenJSONTrailingComma() throws UnsupportedEncodingException {
         try {
-            RDBRow row = new RDBRow("_foo", true, false, 1l, 2l, 3l, "{ \"x\" : 1, }", null);
+            RDBRow row = new RDBRow("_foo", 1L, false, 1l, 2l, 3l, "{ \"x\" : 1, }", null);
             this.ser.fromRow(Collection.NODES, row);
             fail("should fail");
         } catch (DocumentStoreException expected) {
@@ -137,7 +149,7 @@ public class RDBDocumentSerializerTest {
     @Test
     public void testBrokenJSONUnquotedIdentifier() throws UnsupportedEncodingException {
         try {
-            RDBRow row = new RDBRow("_foo", true, false, 1l, 2l, 3l, "{ x : 1, }", null);
+            RDBRow row = new RDBRow("_foo", 1L, false, 1l, 2l, 3l, "{ x : 1, }", null);
             this.ser.fromRow(Collection.NODES, row);
             fail("should fail");
         } catch (DocumentStoreException expected) {
@@ -146,7 +158,7 @@ public class RDBDocumentSerializerTest {
 
     @Test
     public void testSimpleStringNonAscii() {
-        RDBRow row = new RDBRow("_foo", true, false, 1l, 2l, 3l, "{\"x\":\"\u20ac\uD834\uDD1E\"}", null);
+        RDBRow row = new RDBRow("_foo", 1L, false, 1l, 2l, 3l, "{\"x\":\"\u20ac\uD834\uDD1E\"}", null);
         NodeDocument doc = this.ser.fromRow(Collection.NODES, row);
         assertEquals("_foo", doc.getId());
         assertEquals("\u20ac\uD834\uDD1E", doc.get("x"));