From 8c59e64412881db8b9291c68bb49cdfa67e66586 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Sun, 11 Jun 2017 11:51:59 +0200 Subject: 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 --- .../src/org/eclipse/jgit/pgm/Main.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'org.eclipse.jgit.pgm') 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() { -- cgit v1.2.3