[prev in list] [next in list] [prev in thread] [next in thread]
List: httpcomponents-commits
Subject: [httpcomponents-client] branch 5.0.x updated: HTTPCLIENT-2148: fluent Executor volatile access threa
From: ckozak () apache ! org
Date: 2021-04-11 14:33:13
Message-ID: 161815159364.17185.9835475167077167645 () gitbox ! apache ! org
[Download RAW message or body]
This is an automated email from the ASF dual-hosted git repository.
ckozak pushed a commit to branch 5.0.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git
The following commit(s) were added to refs/heads/5.0.x by this push:
new fce5978 HTTPCLIENT-2148: fluent Executor volatile access thread safety \
(#301) fce5978 is described below
commit fce5978dbfe2d075c182f463b6ca0e63839633a1
Author: Carter Kozak <ckozak@apache.org>
AuthorDate: Sun Apr 11 10:29:55 2021 -0400
HTTPCLIENT-2148: fluent Executor volatile access thread safety (#301)
---
.../apache/hc/client5/http/fluent/Executor.java | 38 +++++++++++++---------
1 file changed, 23 insertions(+), 15 deletions(-)
diff --git a/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Executor.java \
b/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Executor.java \
index 29b7023..e067d7d 100644
--- a/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Executor.java
+++ b/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Executor.java
@@ -100,10 +100,12 @@ public class Executor {
}
public Executor auth(final AuthScope authScope, final Credentials credentials) {
- if (this.credentialsStore == null) {
- this.credentialsStore = new BasicCredentialsProvider();
+ CredentialsStore credentialsStoreSnapshot = credentialsStore;
+ if (credentialsStoreSnapshot == null) {
+ credentialsStoreSnapshot = new BasicCredentialsProvider();
+ this.credentialsStore = credentialsStoreSnapshot;
}
- this.credentialsStore.setCredentials(authScope, credentials);
+ credentialsStoreSnapshot.setCredentials(authScope, credentials);
return this;
}
@@ -125,8 +127,9 @@ public class Executor {
}
public Executor authPreemptive(final HttpHost host) {
- if (this.credentialsStore != null) {
- final Credentials credentials = this.credentialsStore.getCredentials(new \
AuthScope(host), null); + final CredentialsStore credentialsStoreSnapshot = \
credentialsStore; + if (credentialsStoreSnapshot != null) {
+ final Credentials credentials = \
credentialsStoreSnapshot.getCredentials(new AuthScope(host), null); if (credentials \
!= null) { final BasicScheme basicScheme = new BasicScheme();
basicScheme.initPreemptive(credentials);
@@ -150,8 +153,9 @@ public class Executor {
}
public Executor authPreemptiveProxy(final HttpHost proxy) {
- if (this.credentialsStore != null) {
- final Credentials credentials = this.credentialsStore.getCredentials(new \
AuthScope(proxy), null); + final CredentialsStore credentialsStoreSnapshot = \
credentialsStore; + if (credentialsStoreSnapshot != null) {
+ final Credentials credentials = \
credentialsStoreSnapshot.getCredentials(new AuthScope(proxy), null); if (credentials \
!= null) { final BasicScheme basicScheme = new BasicScheme();
basicScheme.initPreemptive(credentials);
@@ -186,8 +190,9 @@ public class Executor {
}
public Executor clearAuth() {
- if (this.credentialsStore != null) {
- this.credentialsStore.clear();
+ final CredentialsStore credentialsStoreSnapshot = credentialsStore;
+ if (credentialsStoreSnapshot != null) {
+ credentialsStoreSnapshot.clear();
}
return this;
}
@@ -201,8 +206,9 @@ public class Executor {
}
public Executor clearCookies() {
- if (this.cookieStore != null) {
- this.cookieStore.clear();
+ final CookieStore cookieStoreSnapshot = cookieStore;
+ if (cookieStoreSnapshot != null) {
+ cookieStoreSnapshot.clear();
}
return this;
}
@@ -218,14 +224,16 @@ public class Executor {
public Response execute(
final Request request) throws IOException {
final HttpClientContext localContext = HttpClientContext.create();
- if (this.credentialsStore != null) {
- localContext.setAttribute(HttpClientContext.CREDS_PROVIDER, \
this.credentialsStore); + final CredentialsStore credentialsStoreSnapshot = \
credentialsStore; + if (credentialsStoreSnapshot != null) {
+ localContext.setAttribute(HttpClientContext.CREDS_PROVIDER, \
credentialsStoreSnapshot); }
if (this.authCache != null) {
localContext.setAttribute(HttpClientContext.AUTH_CACHE, this.authCache);
}
- if (this.cookieStore != null) {
- localContext.setAttribute(HttpClientContext.COOKIE_STORE, \
this.cookieStore); + final CookieStore cookieStoreSnapshot = cookieStore;
+ if (cookieStoreSnapshot != null) {
+ localContext.setAttribute(HttpClientContext.COOKIE_STORE, \
cookieStoreSnapshot); }
return new Response(request.internalExecute(this.httpclient, localContext));
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic