summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf <thomas.wolf@paranor.ch>2020-08-20 22:15:11 +0200
committerThomas Wolf <thomas.wolf@paranor.ch>2020-08-20 22:17:40 +0200
commiteec9b55dcf8fc08f431f16eaf139ab009453d445 (patch)
tree27597b8d9ba58adad060229f5841a22a88d80229
parentefd1cc05af7e59a24763dfedb7fc44cda151be50 (diff)
downloadjgit-eec9b55dcf8fc08f431f16eaf139ab009453d445.tar.gz
jgit-eec9b55dcf8fc08f431f16eaf139ab009453d445.zip
FS: don't cache fallback if running in background
If the background job is a little late, the true result might arrive and be cached later. So make sure we don't cache the large fallback resolution in the per-directory cache. Otherwise we'd work with the large fallback until the next restart. Bug: 566170 Change-Id: I7354a6cfddfc0c05144bb0aa41c23029bd4f6af0 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java12
1 files changed, 10 insertions, 2 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 9c5a1e32d3..4d7be0a4ca 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
@@ -294,6 +294,10 @@ public abstract class FS {
return cached;
}
FileStoreAttributes attrs = getFileStoreAttributes(dir);
+ if (attrs == null) {
+ // Don't cache, result might be late
+ return FALLBACK_FILESTORE_ATTRIBUTES;
+ }
attrCacheByPath.put(dir, attrs);
return attrs;
} catch (SecurityException e) {
@@ -382,12 +386,16 @@ public abstract class FS {
});
// even if measuring in background wait a little - if the result
// arrives, it's better than returning the large fallback
- Optional<FileStoreAttributes> d = background.get() ? f.get(
+ boolean runInBackground = background.get();
+ Optional<FileStoreAttributes> d = runInBackground ? f.get(
100, TimeUnit.MILLISECONDS) : f.get();
if (d.isPresent()) {
return d.get();
+ } else if (runInBackground) {
+ // return null until measurement is finished
+ return null;
}
- // return fallback until measurement is finished
+ // fall through and return fallback
} catch (IOException | InterruptedException
| ExecutionException | CancellationException e) {
LOG.error(e.getMessage(), e);