diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2018-09-15 02:35:03 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2018-09-15 09:11:17 +0200 |
commit | e6e9073fc790009f4f7c1b31e5cfea1474972ecc (patch) | |
tree | f8aeab7efca4603ef32c793658af9342823812b5 | |
parent | 667ac8b3189336efbdb0484e212c36beb4ed5338 (diff) | |
download | jgit-e6e9073fc790009f4f7c1b31e5cfea1474972ecc.tar.gz jgit-e6e9073fc790009f4f7c1b31e5cfea1474972ecc.zip |
Fix IOException when LockToken#close fails
This happened if the LockTokens hard link was already deleted earlier.
Bug: 531759
Change-Id: Idc84bd695fac1a763b3cbb797c9c4c636a16e329
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java index 6b537a4775..8d4e5e52af 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -841,13 +841,18 @@ public abstract class FS { @Override public void close() { - if (link.isPresent()) { - try { - Files.delete(link.get()); - } catch (IOException e) { - LOG.error(MessageFormat.format(JGitText.get().closeLockTokenFailed, - this), e); - } + if (!link.isPresent()) { + return; + } + Path p = link.get(); + if (!Files.exists(p)) { + return; + } + try { + Files.delete(p); + } catch (IOException e) { + LOG.error(MessageFormat + .format(JGitText.get().closeLockTokenFailed, this), e); } } |