Add a class for propagating request scoping to different threads
Request scopes are all implemented with ThreadLocals, which meant that RequestScoped data would not be available in any new threads created from the main request thread. Add a class to wrap Runnables and Callables so tasks that depend on request scoped objects can be inserted in a WorkQueue. Include ScopePropagator implementations for all request scope types. The GuiceRequestScopePropagator will forward materialized instances of CurrentUser, RemotePeer SocketAddress, and the CannonicalWebUrl. To support this, CanonicalWebUrlModule is not bound as a SINGLETON anymore and HttpIdentifiedUserProvider implementation now relies on CurrentUser, instead of the WebSession. This was needed because some fields in the HttpRequest object are cleared after the request is finished, but possibly before the propagated request context has been processed. The non guice request scopes do not have this problem, so they can reconstruct the needed objects in the propagated context. Change-Id: I586cd1c91727e2cb8abb166f23fc504e9949a944
This commit is contained in:

committed by
Colby Ranger

parent
2e66220190
commit
3e7ef3cc5f
@@ -32,6 +32,7 @@ import com.google.gerrit.server.git.QueueProvider;
|
||||
import com.google.gerrit.server.git.WorkQueue;
|
||||
import com.google.gerrit.server.project.ProjectControl;
|
||||
import com.google.gerrit.server.ssh.SshInfo;
|
||||
import com.google.gerrit.server.util.RequestScopePropagator;
|
||||
import com.google.gerrit.sshd.args4j.AccountGroupIdHandler;
|
||||
import com.google.gerrit.sshd.args4j.AccountGroupUUIDHandler;
|
||||
import com.google.gerrit.sshd.args4j.AccountIdHandler;
|
||||
@@ -57,6 +58,7 @@ public class SshModule extends FactoryModule {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bindScope(RequestScoped.class, SshScope.REQUEST);
|
||||
bind(RequestScopePropagator.class).to(SshScope.Propagator.class);
|
||||
|
||||
configureRequestScope();
|
||||
configureCmdLineParser();
|
||||
|
Reference in New Issue
Block a user