WebSessionCache: Make response parameter optional
Since I255661a62 WebSession was replaced with DynamicItem<WebSession> in HttpRequestContext to enable plugins to provider alternative implementations of cached web session functionality. One side efect of it is, that now code that is using RequestScopePropagator (with the only available implementation of GuiceRequestScopePropagator) unable to get H2CacheBasedWebSession injected, because it relies on ServletScopes.continueRequest() which doesn't expose HTTP response in the continued request scope: return new Callable<T>() { public T call() throws Exception { checkScopingState(null == GuiceFilter.localContext.get(), "Cannot continue request in the same thread as a HTTP request!"); return new GuiceFilter.Context(continuingRequest, continuingRequest, null) .call(callable); } }; Given that request scope propagation feature is primarly targeting background tasks, make response parameter in CacheBasedWebSession optional and adjust the code to handle this case properly. Change-Id: Iaa5dc15f294a07b83a2411e9f29872df3a82b324
This commit is contained in:

committed by
David Ostrovsky

parent
0927a52b64
commit
ba75ccf8cd
@@ -184,6 +184,10 @@ public abstract class CacheBasedWebSession implements WebSession {
|
||||
}
|
||||
|
||||
private void saveCookie() {
|
||||
if (response == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String token;
|
||||
final int ageSeconds;
|
||||
|
||||
|
@@ -17,6 +17,7 @@ package com.google.gerrit.httpd;
|
||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.extensions.registration.DynamicItem;
|
||||
import com.google.gerrit.httpd.WebSessionManager.Val;
|
||||
import com.google.gerrit.server.AnonymousUser;
|
||||
@@ -56,7 +57,7 @@ public class H2CacheBasedWebSession extends CacheBasedWebSession {
|
||||
@Inject
|
||||
H2CacheBasedWebSession(
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
@Nullable HttpServletResponse response,
|
||||
WebSessionManagerFactory managerFactory,
|
||||
@Named(WebSessionManager.CACHE_NAME) Cache<String, Val> cache,
|
||||
AuthConfig authConfig,
|
||||
|
Reference in New Issue
Block a user