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>
This commit is contained in:
parent
18ae9bb57d
commit
8c59e64412
|
@ -57,6 +57,10 @@
|
|||
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 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 @@ protected void run(final String[] argv) throws Exception {
|
|||
// broken pipe
|
||||
exit(1, null);
|
||||
}
|
||||
gcExecutor.shutdown();
|
||||
gcExecutor.awaitTermination(10, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
PrintWriter createErrorWriter() {
|
||||
|
|
Loading…
Reference in New Issue