diff options
author | Thomas Wolf <thomas.wolf@paranor.ch> | 2019-07-04 09:53:25 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2019-08-08 14:14:38 +0200 |
commit | aefb11298c36960c4ae49fa830c8a93f1171f52f (patch) | |
tree | 4dc0740fa4c50cd1fc87fb0263cf5ef51522e41d | |
parent | f54db4a85701df3209a4c2b473555c704feb6766 (diff) | |
download | jgit-aefb11298c36960c4ae49fa830c8a93f1171f52f.tar.gz jgit-aefb11298c36960c4ae49fa830c8a93f1171f52f.zip |
FS_POSIX: handle Files.getFileStore() failures
Android unconditionally throws a SecurityException;[1] getFileStore()
is not supported. Catch the exception and don't attempt the hard-
linking atomic file mechanism.
[1] https://android.googlesource.com/platform/libcore/+/21e6175e25
Bug: 548947
Change-Id: Idfba2d9dbcbc80ea15ab2ae7889e5142444c1581
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java index faef9fd0f4..6ec50c24e0 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java @@ -396,7 +396,12 @@ public class FS_POSIX extends FS { } Path lockPath = lock.toPath(); Path link = null; - FileStore store = Files.getFileStore(lockPath); + FileStore store = null; + try { + store = Files.getFileStore(lockPath); + } catch (SecurityException e) { + return true; + } try { Boolean canLink = CAN_HARD_LINK.computeIfAbsent(store, s -> Boolean.TRUE); @@ -462,7 +467,12 @@ public class FS_POSIX extends FS { } Path link = null; Path path = file.toPath(); - FileStore store = Files.getFileStore(path); + FileStore store = null; + try { + store = Files.getFileStore(path); + } catch (SecurityException e) { + return token(true, null); + } try { Boolean canLink = CAN_HARD_LINK.computeIfAbsent(store, s -> Boolean.TRUE); |