From 68847a014374e6d62b36185554ab10bcb5509572 Mon Sep 17 00:00:00 2001 From: David Walluck Date: Mon, 24 Aug 2026 12:05:13 -0400 Subject: [PATCH] Keep the supplied cookie store if present --- .../commonjava/util/jhttpc/HttpFactory.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/commonjava/util/jhttpc/HttpFactory.java b/src/main/java/org/commonjava/util/jhttpc/HttpFactory.java index b6cd435..873f9a4 100644 --- a/src/main/java/org/commonjava/util/jhttpc/HttpFactory.java +++ b/src/main/java/org/commonjava/util/jhttpc/HttpFactory.java @@ -224,16 +224,23 @@ public HttpClientContext createContext( final SiteConfig location ) } - CookieStore cookieStore = (CookieStore) location.getAttribute( COOKIE_STORE ); - if ( cookieStore == null ) + if ( ctx.getCookieStore() == null ) { - logger.debug( "Creating CookieStore" ); - cookieStore = new BasicCookieStore(); - location.setAttribute( COOKIE_STORE, cookieStore ); - } + CookieStore cookieStore = (CookieStore) location.getAttribute( COOKIE_STORE ); + if ( cookieStore == null ) + { + logger.debug( "Creating CookieStore" ); + cookieStore = new BasicCookieStore(); + location.setAttribute( COOKIE_STORE, cookieStore ); + } - logger.debug( "Setting CookieStore" ); - ctx.setCookieStore( cookieStore ); + logger.debug( "Setting CookieStore" ); + ctx.setCookieStore( cookieStore ); + } + else + { + logger.debug( "Keeping the supplied CookieStore" ); + } final AuthScope as; try