Make sure the WorkQueue terminates when running command line tools

If we don't call WorkQueue.terminate() the thread pool will stay
running, pegging the JVM open until the user hits Contrl-C in the
tty to break it out.

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2009-02-23 11:30:13 -08:00
parent 4246f380f9
commit b71dca0adb
3 changed files with 31 additions and 1 deletions

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.pgm;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.git.WorkQueue;
import com.google.gerrit.server.GerritServer;
import com.google.gwtjsonrpc.server.XsrfException;
import com.google.gwtorm.client.OrmException;
@@ -25,6 +26,15 @@ import com.google.gwtorm.client.OrmException;
public class CreateSchema {
public static void main(final String[] argv) throws OrmException,
XsrfException {
try {
mainImpl(argv);
} finally {
WorkQueue.terminate();
}
}
private static void mainImpl(final String[] argv) throws OrmException,
XsrfException {
GerritServer.getInstance();
Common.getSchemaFactory().open().close();
System.out.println("Gerrit2 schema initialized");

View File

@@ -28,6 +28,7 @@ import com.google.gerrit.client.reviewdb.SystemConfig;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.git.InvalidRepositoryException;
import com.google.gerrit.git.PatchSetImporter;
import com.google.gerrit.git.WorkQueue;
import com.google.gerrit.server.ChangeUtil;
import com.google.gerrit.server.GerritServer;
import com.google.gwtjsonrpc.server.XsrfException;
@@ -79,7 +80,16 @@ public class ImportGerrit1 {
private static ApprovalCategory submitCategory;
public static void main(final String[] argv) throws OrmException,
XsrfException, SQLException, IOException, InvalidRepositoryException {
XsrfException, IOException, SQLException, InvalidRepositoryException {
try {
mainImpl(argv);
} finally {
WorkQueue.terminate();
}
}
private static void mainImpl(final String[] argv) throws OrmException,
XsrfException, IOException, SQLException, InvalidRepositoryException {
final ProgressMonitor pm = new TextProgressMonitor();
gs = GerritServer.getInstance();
db = Common.getSchemaFactory().open();

View File

@@ -20,6 +20,7 @@ import com.google.gerrit.client.reviewdb.ReviewDb;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.git.InvalidRepositoryException;
import com.google.gerrit.git.PatchSetImporter;
import com.google.gerrit.git.WorkQueue;
import com.google.gerrit.server.GerritServer;
import com.google.gwtjsonrpc.server.XsrfException;
import com.google.gwtorm.client.OrmException;
@@ -54,6 +55,15 @@ import java.util.ArrayList;
public class ReimportPatchSets {
public static void main(final String[] argv) throws OrmException,
XsrfException, IOException {
try {
mainImpl(argv);
} finally {
WorkQueue.terminate();
}
}
private static void mainImpl(final String[] argv) throws OrmException,
XsrfException, IOException {
final GerritServer gs = GerritServer.getInstance();
final ArrayList<PatchSet.Id> todo = new ArrayList<PatchSet.Id>();
final BufferedReader br =