Author: mreutegg Date: Tue May 13 14:24:11 2014 New Revision: 1594236 URL: http://svn.apache.org/r1594236 Log: OAK-1589: MongoDocumentStore fails to report error for keys that are too long
Revert fix to make TCK tests pass again. 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=1594236&r1=1594235&r2=1594236&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 Tue May 13 14:24:11 2014 @@ -16,8 +16,6 @@ */ 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; @@ -25,8 +23,10 @@ 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; @@ -34,6 +34,8 @@ import javax.annotation.CheckForNull; 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; @@ -41,7 +43,7 @@ import org.bson.types.ObjectId; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.mongodb.BasicDBObject; +import static com.google.common.base.Preconditions.checkNotNull; /** * Utility methods. @@ -280,16 +282,15 @@ 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; } @@ -428,9 +429,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); @@ -441,7 +442,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=1594236&r1=1594235&r2=1594236&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 Tue May 13 14:24:11 2014 @@ -21,6 +21,7 @@ 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; @@ -32,8 +33,9 @@ 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();