jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1592535 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/plugins/document/util/Utils.java test/java/org/apache/jackrabbit/oak/plugins/document/MongoDocumentStoreLimitsTest.java
Date Mon, 05 May 2014 14:12:42 GMT
Author: thomasm
Date: Mon May  5 14:12:41 2014
New Revision: 1592535

URL: http://svn.apache.org/r1592535
Log:
OAK-1589 MongoDocumentStore fails to report error for keys that are too long

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/Utils.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoDocumentStoreLimitsTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/Utils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/Utils.java?rev=1592535&r1=1592534&r2=1592535&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/Utils.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/Utils.java
Mon May  5 14:12:41 2014
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.oak.plugins.document.util;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 import java.io.Closeable;
 import java.io.IOException;
 import java.nio.charset.Charset;
@@ -23,18 +25,14 @@ import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.sql.Timestamp;
 import java.util.Comparator;
-import java.util.HashSet;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
 
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
-import com.mongodb.BasicDBObject;
-
 import org.apache.commons.codec.binary.Hex;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.plugins.document.Revision;
@@ -42,7 +40,7 @@ import org.bson.types.ObjectId;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static com.google.common.base.Preconditions.checkNotNull;
+import com.mongodb.BasicDBObject;
 
 /**
  * Utility methods.
@@ -256,15 +254,16 @@ public class Utils {
         if (path.length() < PATH_SHORT) {
             return false;
         }
+        // check if name is too long
+        String name = PathUtils.getName(path);
+        if (name.getBytes(UTF_8).length > NODE_NAME_LIMIT) {
+            throw new IllegalArgumentException("Node name is too long: " + path);
+        }
         // check if the parent path is long
         byte[] parent = PathUtils.getParentPath(path).getBytes(UTF_8);
         if (parent.length < PATH_LONG) {
             return false;
         }
-        String name = PathUtils.getName(path);
-        if (name.getBytes(UTF_8).length > NODE_NAME_LIMIT) {
-            throw new IllegalArgumentException("Node name is too long: " + path);
-        }
         return true;
     }
     
@@ -386,9 +385,9 @@ public class Utils {
      *
      * @param obj object to close
      */
-    public static void closeIfCloseable(Object obj){
-        if(obj instanceof Closeable){
-            try{
+    public static void closeIfCloseable(Object obj) {
+        if (obj instanceof Closeable) {
+            try {
                 ((Closeable) obj).close();
             } catch (IOException e) {
                 LOG.warn("Error occurred while closing {}", obj, e);
@@ -399,7 +398,7 @@ public class Utils {
     /**
      * Provides a readable string for given timestamp
      */
-    public static String timestampToString(long timestamp){
+    public static String timestampToString(long timestamp) {
         return (new Timestamp(timestamp) + "00").substring(0, 23);
     }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoDocumentStoreLimitsTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoDocumentStoreLimitsTest.java?rev=1592535&r1=1592534&r2=1592535&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoDocumentStoreLimitsTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoDocumentStoreLimitsTest.java
Mon May  5 14:12:41 2014
@@ -21,7 +21,6 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
 import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import com.google.common.base.Strings;
@@ -33,9 +32,8 @@ import static junit.framework.Assert.ass
  */
 public class MongoDocumentStoreLimitsTest extends AbstractMongoConnectionTest {
 
-    @Ignore
     @Test
-    public void longName() throws Exception{
+    public void longName() throws Exception {
         DocumentNodeStore ns = mk.getNodeStore();
         NodeBuilder builder = ns.getRoot().builder();
 



Mime
View raw message