diff --git a/pom.xml b/pom.xml
index 1c6c4b63..43c82a55 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0
org.cryptomator
cryptofs
- 1.2.0
+ 1.2.1
Cryptomator Crypto Filesystem
This library provides the Java filesystem provider used by Cryptomator.
https://github.com/cryptomator/cryptofs
diff --git a/src/main/java/org/cryptomator/cryptofs/CryptoPath.java b/src/main/java/org/cryptomator/cryptofs/CryptoPath.java
index 51ca7f77..6969671b 100644
--- a/src/main/java/org/cryptomator/cryptofs/CryptoPath.java
+++ b/src/main/java/org/cryptomator/cryptofs/CryptoPath.java
@@ -94,8 +94,10 @@ public CryptoPath getParent() {
if (elementCount > 1) {
List elems = elements.subList(0, elementCount - 1);
return copyWithElements(elems);
- } else {
+ } else if (elementCount == 1) {
return getRoot();
+ } else {
+ return null;
}
}
diff --git a/src/test/java/org/cryptomator/cryptofs/CryptoPathTest.java b/src/test/java/org/cryptomator/cryptofs/CryptoPathTest.java
index c6cd3c2e..c2e12b15 100644
--- a/src/test/java/org/cryptomator/cryptofs/CryptoPathTest.java
+++ b/src/test/java/org/cryptomator/cryptofs/CryptoPathTest.java
@@ -119,11 +119,13 @@ public void testGetParent() {
Path p1 = path("/foo");
Path p2 = path("/foo/bar");
Path p3 = path("foo");
+ Path p4 = path("/");
Assert.assertEquals(p1, p2.getParent());
Assert.assertEquals(rootPath, p1.getParent());
Assert.assertNull(emptyPath.getParent());
Assert.assertNull(p3.getParent());
+ Assert.assertNull(p4.getParent());
}
@Test