From 8f674047660371e746d4a83714b44a7cd7f6b714 Mon Sep 17 00:00:00 2001 From: JaniruTEC <52893617+JaniruTEC@users.noreply.github.com> Date: Fri, 21 Jul 2023 15:35:56 +0200 Subject: [PATCH] Fixed method violating API contract See: https://github.com/cryptomator/cryptomator/pull/2996#discussion_r1269458822 --- .../common/mount/MountWithinParentUtilTest.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/cryptomator/common/mount/MountWithinParentUtilTest.java b/src/test/java/org/cryptomator/common/mount/MountWithinParentUtilTest.java index bf637006c..49a6e4049 100644 --- a/src/test/java/org/cryptomator/common/mount/MountWithinParentUtilTest.java +++ b/src/test/java/org/cryptomator/common/mount/MountWithinParentUtilTest.java @@ -1,6 +1,5 @@ package org.cryptomator.common.mount; -import org.apache.commons.lang3.SystemUtils; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledOnOs; import org.junit.jupiter.api.condition.EnabledOnOs; @@ -12,6 +11,7 @@ import java.io.IOException; import java.nio.file.DirectoryNotEmptyException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Objects; import static java.nio.file.LinkOption.NOFOLLOW_LINKS; import static org.cryptomator.common.mount.MountWithinParentUtil.cleanup; @@ -22,7 +22,6 @@ import static org.cryptomator.common.mount.MountWithinParentUtil.removeResidualJ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assumptions.assumeTrue; @@ -202,6 +201,10 @@ class MountWithinParentUtilTest { } private static boolean isHidden(Path path) throws IOException { - return (boolean) Files.getAttribute(path, "dos:hidden", NOFOLLOW_LINKS); + try { + return (boolean) Objects.requireNonNullElse(Files.getAttribute(path, "dos:hidden", NOFOLLOW_LINKS), false); + } catch (UnsupportedOperationException | IllegalMountPointException e) { + return false; + } } } \ No newline at end of file