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>
This commit is contained in:
Matthias Sohn 2018-09-15 02:35:03 +02:00
parent 667ac8b318
commit e6e9073fc7
1 changed files with 12 additions and 7 deletions

View File

@ -841,13 +841,18 @@ public boolean isCreated() {
@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);
}
}