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 ch...@apache.org on 2013/12/11 15:54:50 UTC

svn commit: r1550162 - /jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java

Author: chetanm
Date: Wed Dec 11 14:54:49 2013
New Revision: 1550162

URL: http://svn.apache.org/r1550162
Log:
OAK-1277 - PathUtils assertion failed error should also include invalid path

Adding message clause to assertions which include path details

Modified:
    jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java

Modified: jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java?rev=1550162&r1=1550161&r2=1550162&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java (original)
+++ jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java Wed Dec 11 14:54:49 2013
@@ -47,7 +47,7 @@ public final class PathUtils {
      * @return whether this is the root
      */
     public static boolean denotesRoot(String path) {
-        assert isValid(path);
+        assert isValid(path) : "Invalid path ["+path+"]";
 
         return denotesRootPath(path);
     }
@@ -79,7 +79,7 @@ public final class PathUtils {
      * @return true if it starts with a slash
      */
     public static boolean isAbsolute(String path) {
-        assert isValid(path);
+        assert isValid(path) : "Invalid path ["+path+"]";
 
         return isAbsolutePath(path);
     }
@@ -113,7 +113,7 @@ public final class PathUtils {
      */
     @Nonnull
     public static String getAncestorPath(String path, int nth) {
-        assert isValid(path);
+        assert isValid(path) : "Invalid path ["+path+"]";
 
         if (path.isEmpty() || denotesRootPath(path)
                 || nth <= 0) {
@@ -145,7 +145,7 @@ public final class PathUtils {
      */
     @Nonnull
     public static String getName(String path) {
-        assert isValid(path);
+        assert isValid(path) : "Invalid path ["+path+"]";
 
         if (path.isEmpty() || denotesRootPath(path)) {
             return "";
@@ -183,7 +183,7 @@ public final class PathUtils {
      * @return the number of elements
      */
     public static int getDepth(String path) {
-        assert isValid(path);
+        assert isValid(path) : "Invalid path ["+path+"]";
 
         if (path.isEmpty()) {
             return 0;
@@ -213,7 +213,7 @@ public final class PathUtils {
      */
     @Nonnull
     public static Iterable<String> elements(final String path) {
-        assert isValid(path);
+        assert isValid(path) : "Invalid path ["+path+"]";
 
         final Iterator<String> it = new Iterator<String>() {
             int pos = PathUtils.isAbsolute(path) ? 1 : 0;
@@ -270,7 +270,7 @@ public final class PathUtils {
      */
     @Nonnull
     public static String concat(String parentPath, String... relativePaths) {
-        assert isValid(parentPath);
+        assert isValid(parentPath) : "Invalid parent path ["+parentPath+"]";
         int parentLen = parentPath.length();
         int size = relativePaths.length;
         StringBuilder buff = new StringBuilder(parentLen + size * 5);
@@ -301,8 +301,8 @@ public final class PathUtils {
      */
     @Nonnull
     public static String concat(String parentPath, String subPath) {
-        assert isValid(parentPath);
-        assert isValid(subPath);
+        assert isValid(parentPath) : "Invalid parent path ["+parentPath+"]";
+        assert isValid(subPath) : "Invalid sub path ["+subPath+"]";
         // special cases
         if (parentPath.isEmpty()) {
             return subPath;
@@ -327,8 +327,8 @@ public final class PathUtils {
      * @return true if the path is an offspring of the ancestor
      */
     public static boolean isAncestor(String ancestor, String path) {
-        assert isValid(ancestor);
-        assert isValid(path);
+        assert isValid(ancestor) : "Invalid parent path ["+ancestor+"]";
+        assert isValid(path) : "Invalid path ["+ancestor+"]";
         if (ancestor.isEmpty() || path.isEmpty()) {
             return false;
         }
@@ -353,8 +353,8 @@ public final class PathUtils {
      */
     @Nonnull
     public static String relativize(String parentPath, String path) {
-        assert isValid(parentPath);
-        assert isValid(path);
+        assert isValid(parentPath) : "Invalid parent path ["+parentPath+"]";
+        assert isValid(path) : "Invalid path ["+path+"]";
 
         if (parentPath.equals(path)) {
             return "";
@@ -379,7 +379,7 @@ public final class PathUtils {
      *         if not found
      */
     public static int getNextSlash(String path, int index) {
-        assert isValid(path);
+        assert isValid(path) : "Invalid path ["+path+"]";
 
         return path.indexOf('/', index);
     }