configSubsectionContainsNullByte=config subsection name contains byte 0x00
configValueContainsNullByte=config value contains byte 0x00
configHandleIsStale=config file handle is stale, {0}. retry
+configHandleMayBeLocked=config file handle may be locked by other process, {0}. retry
connectionFailed=connection failed
connectionTimeOut=Connection time out: {0}
contextMustBeNonNegative=context must be >= 0
/***/ public String configSubsectionContainsNullByte;
/***/ public String configValueContainsNullByte;
/***/ public String configHandleIsStale;
+ /***/ public String configHandleMayBeLocked;
/***/ public String connectionFailed;
/***/ public String connectionTimeOut;
/***/ public String contextMustBeNonNegative;
*/
@Override
public void load() throws IOException, ConfigInvalidException {
- final int maxStaleRetries = 5;
+ final int maxRetries = 5;
+ int retryDelayMillis = 20;
int retries = 0;
while (true) {
final FileSnapshot oldSnapshot = snapshot;
}
return;
} catch (FileNotFoundException noFile) {
+ // might be locked by another process (see exception Javadoc)
+ if (retries < maxRetries && configFile.exists()) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(MessageFormat.format(
+ JGitText.get().configHandleMayBeLocked,
+ Integer.valueOf(retries)), noFile);
+ }
+ try {
+ Thread.sleep(retryDelayMillis);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+ retries++;
+ retryDelayMillis *= 2; // max wait 1260 ms
+ continue;
+ }
if (configFile.exists()) {
throw noFile;
}
return;
} catch (IOException e) {
if (FileUtils.isStaleFileHandle(e)
- && retries < maxStaleRetries) {
+ && retries < maxRetries) {
if (LOG.isDebugEnabled()) {
LOG.debug(MessageFormat.format(
JGitText.get().configHandleIsStale,