Skip to content

Commit 6afba08

Browse files
committed
Release 2.12.4 with CVE Fix: 2024-53990
1 parent 7a370af commit 6afba08

File tree

17 files changed

+77
-60
lines changed

17 files changed

+77
-60
lines changed

bom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.asynchttpclient</groupId>
77
<artifactId>async-http-client-project</artifactId>
8-
<version>2.12.3</version>
8+
<version>2.12.4</version>
99
</parent>
1010

1111
<artifactId>async-http-client-bom</artifactId>

client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<parent>
33
<groupId>org.asynchttpclient</groupId>
44
<artifactId>async-http-client-project</artifactId>
5-
<version>2.12.3</version>
5+
<version>2.12.4</version>
66
</parent>
77
<modelVersion>4.0.0</modelVersion>
88
<artifactId>async-http-client</artifactId>

client/src/main/java/org/asynchttpclient/DefaultAsyncHttpClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public <T> ListenableFuture<T> executeRequest(Request request, AsyncHandler<T> h
214214
if (!cookies.isEmpty()) {
215215
RequestBuilder requestBuilder = request.toBuilder();
216216
for (Cookie cookie : cookies) {
217-
requestBuilder.addOrReplaceCookie(cookie);
217+
requestBuilder.addCookieIfUnset(cookie);
218218
}
219219
request = requestBuilder.build();
220220
}

client/src/main/java/org/asynchttpclient/RequestBuilderBase.java

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,26 +308,43 @@ public T addCookie(Cookie cookie) {
308308

309309
/**
310310
* Add/replace a cookie based on its name
311+
*
311312
* @param cookie the new cookie
312313
* @return this
313314
*/
314315
public T addOrReplaceCookie(Cookie cookie) {
316+
return maybeAddOrReplaceCookie(cookie, true);
317+
}
318+
319+
/**
320+
* Add a cookie based on its name, if it does not exist yet. Cookies that
321+
* are already set will be ignored.
322+
*
323+
* @param cookie the new cookie
324+
* @return this
325+
*/
326+
public T addCookieIfUnset(Cookie cookie) {
327+
return maybeAddOrReplaceCookie(cookie, false);
328+
}
329+
330+
private T maybeAddOrReplaceCookie(Cookie cookie, boolean allowReplace) {
315331
String cookieKey = cookie.name();
316332
boolean replace = false;
317333
int index = 0;
318334
lazyInitCookies();
319-
for (Cookie c : this.cookies) {
335+
for (Cookie c : cookies) {
320336
if (c.name().equals(cookieKey)) {
321337
replace = true;
322338
break;
323339
}
324340

325341
index++;
326342
}
327-
if (replace)
328-
this.cookies.set(index, cookie);
329-
else
330-
this.cookies.add(cookie);
343+
if (!replace) {
344+
cookies.add(cookie);
345+
} else if (allowReplace) {
346+
cookies.set(index, cookie);
347+
}
331348
return asDerivedType();
332349
}
333350

client/src/main/java/org/asynchttpclient/netty/handler/intercept/Redirect30xInterceptor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,9 @@ else if (isNonEmpty(request.getBodyParts())) {
135135
// Update request's cookies assuming that cookie store is already updated by Interceptors
136136
List<Cookie> cookies = cookieStore.get(newUri);
137137
if (!cookies.isEmpty())
138-
for (Cookie cookie : cookies)
139-
requestBuilder.addOrReplaceCookie(cookie);
138+
for (Cookie cookie : cookieStore.get(newUri)) {
139+
requestBuilder.addCookieIfUnset(cookie);
140+
}
140141
}
141142

142143
boolean sameBase = request.getUri().isSameBase(newUri);

example/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<parent>
33
<groupId>org.asynchttpclient</groupId>
44
<artifactId>async-http-client-project</artifactId>
5-
<version>2.12.3</version>
5+
<version>2.12.4</version>
66
</parent>
77
<modelVersion>4.0.0</modelVersion>
88
<artifactId>async-http-client-example</artifactId>

extras/guava/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<parent>
33
<groupId>org.asynchttpclient</groupId>
44
<artifactId>async-http-client-extras-parent</artifactId>
5-
<version>2.12.3</version>
5+
<version>2.12.4</version>
66
</parent>
77
<modelVersion>4.0.0</modelVersion>
88
<artifactId>async-http-client-extras-guava</artifactId>

extras/jdeferred/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<parent>
1919
<artifactId>async-http-client-extras-parent</artifactId>
2020
<groupId>org.asynchttpclient</groupId>
21-
<version>2.12.3</version>
21+
<version>2.12.4</version>
2222
</parent>
2323
<artifactId>async-http-client-extras-jdeferred</artifactId>
2424
<name>Asynchronous Http Client JDeferred Extras</name>

extras/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<parent>
33
<groupId>org.asynchttpclient</groupId>
44
<artifactId>async-http-client-project</artifactId>
5-
<version>2.12.3</version>
5+
<version>2.12.4</version>
66
</parent>
77
<modelVersion>4.0.0</modelVersion>
88
<artifactId>async-http-client-extras-parent</artifactId>

extras/registry/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<parent>
33
<groupId>org.asynchttpclient</groupId>
44
<artifactId>async-http-client-extras-parent</artifactId>
5-
<version>2.12.3</version>
5+
<version>2.12.4</version>
66
</parent>
77
<modelVersion>4.0.0</modelVersion>
88
<artifactId>async-http-client-extras-registry</artifactId>

0 commit comments

Comments
 (0)