CommandExecutorQueueProvider: Fix singleton binding

Binding the class with in(SINGLETON) creates a singleton per injector,
and because it is done in two injectors (the SSH injector and the HTTP
injector), we end up with two instances and thus two work queues for
both SSH-Interactive-Worker and SSH-Batch-Worker.

Remove the in(SINGLETON) and instead explicitly make the class singleton
by annotating with @Singleton

Change-Id: Ifa782b7ea7f97d88d0afdfa9efc87ad7baa15b93
Signed-off-by: Eryk Szymanski <eryksz@gmail.com>
Signed-off-by: David Pursehouse <dpursehouse@collab.net>
This commit is contained in:
Eryk Szymanski
2018-04-26 23:46:37 +02:00
committed by David Pursehouse
parent 89050c03bc
commit ec304a1098
3 changed files with 4 additions and 3 deletions

View File

@@ -15,7 +15,6 @@
package com.google.gerrit.pgm.http.jetty;
import static com.google.gerrit.server.config.ConfigUtil.getTimeUnit;
import static com.google.inject.Scopes.SINGLETON;
import static java.util.concurrent.TimeUnit.MINUTES;
import static javax.servlet.http.HttpServletResponse.SC_SERVICE_UNAVAILABLE;
@@ -72,7 +71,7 @@ public class ProjectQoSFilter implements Filter {
@Override
protected void configureServlets() {
bind(QueueProvider.class).to(CommandExecutorQueueProvider.class).in(SINGLETON);
bind(QueueProvider.class).to(CommandExecutorQueueProvider.class);
filterRegex(FILTER_RE).through(ProjectQoSFilter.class);
}
}

View File

@@ -19,9 +19,11 @@ import com.google.gerrit.server.config.ThreadSettingsConfig;
import com.google.gerrit.server.git.QueueProvider;
import com.google.gerrit.server.git.WorkQueue;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.concurrent.ThreadFactory;
import org.eclipse.jgit.lib.Config;
@Singleton
public class CommandExecutorQueueProvider implements QueueProvider {
private int poolSize;

View File

@@ -80,7 +80,7 @@ public class SshModule extends LifecycleModule {
.annotatedWith(StreamCommandExecutor.class)
.toProvider(StreamCommandExecutorProvider.class)
.in(SINGLETON);
bind(QueueProvider.class).to(CommandExecutorQueueProvider.class).in(SINGLETON);
bind(QueueProvider.class).to(CommandExecutorQueueProvider.class);
bind(GSSAuthenticator.class).to(GerritGSSAuthenticator.class);
bind(PublickeyAuthenticator.class).to(CachingPublicKeyAuthenticator.class);