brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [1/5] brooklyn-server git commit: Os.isAbsolutish works for blank strings
Date Thu, 21 Apr 2016 08:45:48 GMT
Repository: brooklyn-server
Updated Branches:
  refs/heads/master bc0362bac -> df406eb7b


Os.isAbsolutish works for blank strings


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/940388f1
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/940388f1
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/940388f1

Branch: refs/heads/master
Commit: 940388f18fe6db02d508550bc88ffeddc2c94b8b
Parents: 3b746e3
Author: Sam Corbett <sam.corbett@cloudsoftcorp.com>
Authored: Wed Apr 13 16:55:08 2016 +0100
Committer: Sam Corbett <sam.corbett@cloudsoftcorp.com>
Committed: Wed Apr 13 17:06:42 2016 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/brooklyn/util/os/Os.java    | 10 +++++-----
 .../test/java/org/apache/brooklyn/util/os/OsTest.java    | 11 ++++++++++-
 2 files changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/940388f1/utils/common/src/main/java/org/apache/brooklyn/util/os/Os.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/org/apache/brooklyn/util/os/Os.java b/utils/common/src/main/java/org/apache/brooklyn/util/os/Os.java
index 75247ab..6ff2b3a 100644
--- a/utils/common/src/main/java/org/apache/brooklyn/util/os/Os.java
+++ b/utils/common/src/main/java/org/apache/brooklyn/util/os/Os.java
@@ -497,11 +497,11 @@ public class Os {
      * @return whether the path is absolute under the above constraints.
      */
     public static boolean isAbsolutish(String path) {
-        return
-            path.codePointAt(0) == SEPARATOR_UNIX ||
-            path.equals("~") || path.startsWith("~" + SEPARATOR_UNIX) ||
-            path.length()>=3 && path.codePointAt(1) == ':' &&
-                                isSeparator(path.codePointAt(2));
+        return Strings.isNonBlank(path) &&
+                (path.codePointAt(0) == SEPARATOR_UNIX ||
+                        path.equals("~") ||
+                        path.startsWith("~" + SEPARATOR_UNIX) ||
+                        (path.length() >= 3 && path.codePointAt(1) == ':' &&
isSeparator(path.codePointAt(2))));
     }
 
     /** @deprecated since 0.7.0, use {@link #isAbsolutish(String)} */

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/940388f1/utils/common/src/test/java/org/apache/brooklyn/util/os/OsTest.java
----------------------------------------------------------------------
diff --git a/utils/common/src/test/java/org/apache/brooklyn/util/os/OsTest.java b/utils/common/src/test/java/org/apache/brooklyn/util/os/OsTest.java
index e3792a0..b39b210 100644
--- a/utils/common/src/test/java/org/apache/brooklyn/util/os/OsTest.java
+++ b/utils/common/src/test/java/org/apache/brooklyn/util/os/OsTest.java
@@ -43,7 +43,16 @@ import com.google.common.io.Files;
 public class OsTest {
 
     private static final Logger log = LoggerFactory.getLogger(OsTest.class);
-    
+
+    public void testIsAbsolutish() {
+        assertFalse(Os.isAbsolutish(""));
+        assertFalse(Os.isAbsolutish("foo/bar"));
+        assertTrue(Os.isAbsolutish("/"));
+        assertTrue(Os.isAbsolutish("~/"));
+        assertTrue(Os.isAbsolutish("~"));
+        assertTrue(Os.isAbsolutish("/foo/bar"));
+    }
+
     public void testTmp() {
         log.info("tmp dir is: "+Os.tmp());
         Assert.assertNotNull(Os.tmp());


Mime
View raw message