jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1408693 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/kernel/TypeCodes.java test/java/org/apache/jackrabbit/oak/kernel/TypeCodesTest.java
Date Tue, 13 Nov 2012 12:20:08 GMT
Author: mduerig
Date: Tue Nov 13 12:20:07 2012
New Revision: 1408693

URL: http://svn.apache.org/viewvc?rev=1408693&view=rev
Log:
OAK-428: Binaries might get removed by garbage collection while still referenced
change prefix for binaries from bin: to :blobId:

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/TypeCodes.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/TypeCodesTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/TypeCodes.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/TypeCodes.java?rev=1408693&r1=1408692&r2=1408693&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/TypeCodes.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/TypeCodes.java
Tue Nov 13 12:20:07 2012
@@ -34,7 +34,9 @@ public class TypeCodes {
 
     static {
         for (int type = PropertyType.UNDEFINED; type <= PropertyType.DECIMAL; type++)
{
-            String code = PropertyType.nameFromValue(type).substring(0, 3).toLowerCase(Locale.ENGLISH);
+            String code = type == PropertyType.BINARY
+                    ? ":blobId"  // See class comment for MicroKernel and OAK-428
+                    : PropertyType.nameFromValue(type).substring(0, 3).toLowerCase(Locale.ENGLISH);
             TYPE2CODE.put(type, code);
             CODE2TYPE.put(code, type);
         }
@@ -61,7 +63,10 @@ public class TypeCodes {
      * @return  the location where the prefix ends or -1 if no prefix is present
      */
     public static int split(String jsonString) {
-        if (jsonString.length() >= 4 && jsonString.charAt(3) == ':') {
+        if (jsonString.startsWith(":blobId:")) {  // See OAK-428
+            return 7;
+        }
+        else if (jsonString.length() >= 4 && jsonString.charAt(3) == ':') {
             return 3;
         }
         else {
@@ -82,8 +87,8 @@ public class TypeCodes {
         else {
             Integer type = CODE2TYPE.get(jsonString.substring(0, split));
             return type == null
-                ? PropertyType.UNDEFINED
-                : type;
+                    ? PropertyType.UNDEFINED
+                    : type;
         }
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/TypeCodesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/TypeCodesTest.java?rev=1408693&r1=1408692&r2=1408693&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/TypeCodesTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/TypeCodesTest.java
Tue Nov 13 12:20:07 2012
@@ -28,7 +28,7 @@ public class TypeCodesTest {
     @Test
     public void testEncode() {
         assertEquals("str:foo", TypeCodes.encode(PropertyType.STRING, "foo"));
-        assertEquals("bin:", TypeCodes.encode(PropertyType.BINARY, ""));
+        assertEquals(":blobId:", TypeCodes.encode(PropertyType.BINARY, ""));
         assertEquals("und:foo", TypeCodes.encode(PropertyType.UNDEFINED, "foo"));
     }
 



Mime
View raw message