aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2019-08-12 17:40:39 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2019-08-13 08:33:32 +0200
commit2d84bb43410469b44bca145c3d06a0386c0e2175 (patch)
tree0e6a74c2d8cbdbc108a3318b7bc971e39a61a5f4 /org.eclipse.jgit/src
parentcb53db4bffd84275b2bbba6952050922ed42c9c5 (diff)
downloadjgit-2d84bb43410469b44bca145c3d06a0386c0e2175.tar.gz
jgit-2d84bb43410469b44bca145c3d06a0386c0e2175.zip
Improve retry handling when saving FileStoreAttributes fails
- fix handling of interrupts in FileStoreAttributes#saveToConfig - increase retry wait time to 100ms - don't wait after last retry - dont retry if failure is caused by another exception than LockFailedException Change-Id: I108c012717d2bcce71f2c6cb9cf0879de704ebc2 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java1
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java18
2 files changed, 15 insertions, 4 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
index 23950100d2..a6110e57d5 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
@@ -491,6 +491,7 @@ public class JGitText extends TranslationBundle {
/***/ public String localRepository;
/***/ public String lockCountMustBeGreaterOrEqual1;
/***/ public String lockError;
+ /***/ public String lockFailedRetry;
/***/ public String lockOnNotClosed;
/***/ public String lockOnNotHeld;
/***/ public String malformedpersonIdentString;
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 509e6d2280..6efd02f479 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
@@ -580,20 +580,30 @@ public abstract class FS {
} catch (LockFailedException e) {
// race with another thread, wait a bit and try again
try {
- LOG.warn(MessageFormat.format(JGitText.get().cannotLock,
- userConfig));
retries++;
- Thread.sleep(20);
+ if (retries < max_retries) {
+ Thread.sleep(100);
+ LOG.debug("locking {} failed, retries {}/{}", //$NON-NLS-1$
+ userConfig, Integer.valueOf(retries),
+ Integer.valueOf(max_retries));
+ } else {
+ LOG.warn(MessageFormat.format(
+ JGitText.get().lockFailedRetry, userConfig,
+ Integer.valueOf(retries)));
+ }
} catch (InterruptedException e1) {
- Thread.interrupted();
+ Thread.currentThread().interrupt();
+ break;
}
} catch (IOException e) {
LOG.error(MessageFormat.format(
JGitText.get().cannotSaveConfig, userConfig), e);
+ break;
} catch (ConfigInvalidException e) {
LOG.error(MessageFormat.format(
JGitText.get().repositoryConfigFileInvalid,
userConfig, e.getMessage()));
+ break;
}
}
}