aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java20
2 files changed, 13 insertions, 13 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java
index b5fff7d6d7..584d2bc394 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java
@@ -14,6 +14,7 @@ import java.text.MessageFormat;
import java.text.ParseException;
import java.util.Date;
import java.util.Properties;
+import java.util.concurrent.ExecutionException;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.JGitInternalException;
@@ -176,9 +177,10 @@ public class GarbageCollectCommand extends GitCommand<Properties> {
gc.setExpire(expire);
try {
- gc.gc();
+ gc.gc().get();
return toProperties(gc.getStatistics());
- } catch (ParseException e) {
+ } catch (ParseException | InterruptedException
+ | ExecutionException e) {
throw new JGitInternalException(JGitText.get().gcFailed, e);
}
} else if (repo instanceof DfsRepository) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
index 93c6201597..ca4f7a21e3 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
@@ -12,8 +12,8 @@ package org.eclipse.jgit.internal.storage.file;
import static org.eclipse.jgit.internal.storage.pack.PackExt.BITMAP_INDEX;
import static org.eclipse.jgit.internal.storage.pack.PackExt.INDEX;
-import static org.eclipse.jgit.internal.storage.pack.PackExt.PACK;
import static org.eclipse.jgit.internal.storage.pack.PackExt.KEEP;
+import static org.eclipse.jgit.internal.storage.pack.PackExt.PACK;
import java.io.File;
import java.io.FileOutputStream;
@@ -46,8 +46,9 @@ import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
-import java.util.concurrent.Callable;
+import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
+import java.util.function.Supplier;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -214,19 +215,18 @@ public class GC {
* If the configuration parameter "gc.pruneexpire" couldn't be
* parsed
*/
- // TODO(ms): change signature and return Future<Collection<Pack>>
- @SuppressWarnings("FutureReturnValueIgnored")
- public Collection<Pack> gc() throws IOException, ParseException {
+ public CompletableFuture<Collection<Pack>> gc()
+ throws IOException, ParseException {
if (!background) {
- return doGc();
+ return CompletableFuture.completedFuture(doGc());
}
final GcLog gcLog = new GcLog(repo);
if (!gcLog.lock()) {
// there is already a background gc running
- return Collections.emptyList();
+ return CompletableFuture.completedFuture(Collections.emptyList());
}
- Callable<Collection<Pack>> gcTask = () -> {
+ Supplier<Collection<Pack>> gcTask = () -> {
try {
Collection<Pack> newPacks = doGc();
if (automatic && tooManyLooseObjects()) {
@@ -251,9 +251,7 @@ public class GC {
}
return Collections.emptyList();
};
- // TODO(ms): change signature and return the Future
- executor().submit(gcTask);
- return Collections.emptyList();
+ return CompletableFuture.supplyAsync(gcTask, executor());
}
private ExecutorService executor() {