summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm/src
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2017-06-11 11:51:59 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2017-06-11 12:24:12 +0200
commit8c59e64412881db8b9291c68bb49cdfa67e66586 (patch)
tree43082173fbd6530fb8454d7c8578e37887cd290d /org.eclipse.jgit.pgm/src
parent18ae9bb57db46d7d8720394cf409d56cd4b750f7 (diff)
downloadjgit-8c59e64412881db8b9291c68bb49cdfa67e66586.tar.gz
jgit-8c59e64412881db8b9291c68bb49cdfa67e66586.zip
Use a dedicated executor to run auto-gc in command line interface
WorkQueue uses daemon threads so auto-gc would not be executed after short-lived commands run in command line. Hence use a dedicated executor which we shutdown when the command finishes. Change-Id: I0c2429ecfa04387389d159168ba78a020a696228 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.pgm/src')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java
index a9f428e02d..c94ba0bd86 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java
@@ -57,6 +57,10 @@ import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
import org.eclipse.jgit.awtui.AwtAuthenticator;
import org.eclipse.jgit.awtui.AwtCredentialsProvider;
@@ -98,6 +102,8 @@ public class Main {
PrintWriter writer;
+ private ExecutorService gcExecutor;
+
/**
*
*/
@@ -105,6 +111,17 @@ public class Main {
HttpTransport.setConnectionFactory(new HttpClientConnectionFactory());
CleanFilter.register();
SmudgeFilter.register();
+ gcExecutor = Executors.newSingleThreadExecutor(new ThreadFactory() {
+ private final ThreadFactory baseFactory = Executors
+ .defaultThreadFactory();
+
+ @Override
+ public Thread newThread(Runnable taskBody) {
+ Thread thr = baseFactory.newThread(taskBody);
+ thr.setName("JGit-autoGc"); //$NON-NLS-1$
+ return thr;
+ }
+ });
}
/**
@@ -192,6 +209,8 @@ public class Main {
// broken pipe
exit(1, null);
}
+ gcExecutor.shutdown();
+ gcExecutor.awaitTermination(10, TimeUnit.MINUTES);
}
PrintWriter createErrorWriter() {