From 8d0c90eef9820bce6933fe8d4dc72ebf267963cf Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Wed, 12 Dec 2012 14:54:22 +0100 Subject: [PATCH] Recreating the CookieManager if the CookieStore is changed. --- .../java/org/eclipse/jetty/client/HttpClient.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java index 309bbc42610..b6372992351 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java @@ -33,6 +33,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Locale; +import java.util.Objects; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -203,7 +204,7 @@ public class HttpClient extends ContainerLifeCycle decoderFactories.add(new GZIPContentDecoder.Factory()); - cookieManager = new CookieManager(cookieStore, CookiePolicy.ACCEPT_ALL); + cookieManager = newCookieManager(); cookieStore = cookieManager.getCookieStore(); super.doStart(); @@ -216,6 +217,11 @@ public class HttpClient extends ContainerLifeCycle return new ClientSelectorManager(getExecutor(), getScheduler()); } + private CookieManager newCookieManager() + { + return new CookieManager(getCookieStore(), CookiePolicy.ACCEPT_ALL); + } + @Override protected void doStop() throws Exception { @@ -261,7 +267,8 @@ public class HttpClient extends ContainerLifeCycle */ public void setCookieStore(CookieStore cookieStore) { - this.cookieStore = cookieStore; + this.cookieStore = Objects.requireNonNull(cookieStore); + this.cookieManager = newCookieManager(); } /**