Skip to content

Commit 80901cf

Browse files
committed
Merge remote-tracking branch 'upstream/3.0' into 'upstream/3.1'
Signed-off-by: Maxim Nesen <[email protected]>
2 parents 92a1448 + 853b033 commit 80901cf

File tree

128 files changed

+15264
-683
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+15264
-683
lines changed

NOTICE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Javassist Version 3.30.2-GA
7070
* Project: http://www.javassist.org/
7171
* Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
7272

73-
Jackson JAX-RS Providers Version 2.18.0
73+
Jackson JAX-RS Providers Version 2.19.1
7474
* License: Apache License, 2.0
7575
* Project: https://github.com/FasterXML/jackson-jaxrs-providers
7676
* Copyright: (c) 2009-2024 FasterXML, LLC. All rights reserved unless otherwise indicated.
@@ -95,7 +95,7 @@ KineticJS, v4.7.1
9595
* Project: http://www.kineticjs.com, https://github.com/ericdrowell/KineticJS
9696
* Copyright: Eric Rowell
9797

98-
org.objectweb.asm Version 9.8
98+
org.objectweb.asm Version 9.9
9999
* License: Modified BSD (https://asm.ow2.io/license.html)
100100
* Copyright (c) 2000-2011 INRIA, France Telecom. All rights reserved.
101101

bom/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@
178178
<artifactId>jersey-bean-validation</artifactId>
179179
<version>${project.version}</version>
180180
</dependency>
181+
<dependency>
182+
<groupId>org.glassfish.jersey.ext</groupId>
183+
<artifactId>jersey-constants</artifactId>
184+
<version>${project.version}</version>
185+
</dependency>
181186
<dependency>
182187
<groupId>org.glassfish.jersey.ext</groupId>
183188
<artifactId>jersey-entity-filtering</artifactId>

connectors/helidon-connector/pom.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,6 @@
7676
<artifactId>maven-compiler-plugin</artifactId>
7777
<inherited>false</inherited>
7878
</plugin>
79-
<plugin>
80-
<groupId>org.apache.maven.plugins</groupId>
81-
<artifactId>maven-javadoc-plugin</artifactId>
82-
<configuration>
83-
<source>8</source>
84-
<detectJavaApiLink>false</detectJavaApiLink>
85-
</configuration>
86-
</plugin>
8779
</plugins>
8880
</build>
8981

connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/Expect100ContinueConnectorExtension.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2023, 2025 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -30,20 +30,21 @@
3030

3131
class Expect100ContinueConnectorExtension
3232
implements ConnectorExtension<HttpRequest, IOException> {
33+
34+
private final NettyConnectorProvider.Config.RW requestConfiguration;
35+
36+
Expect100ContinueConnectorExtension(NettyConnectorProvider.Config.RW requestConfiguration) {
37+
this.requestConfiguration = requestConfiguration;
38+
}
39+
3340
private static final String EXCEPTION_MESSAGE = "Server rejected operation";
3441
@Override
3542
public void invoke(ClientRequest request, HttpRequest extensionParam) {
3643

3744
final long length = request.getLengthLong();
38-
final RequestEntityProcessing entityProcessing = request.resolveProperty(
39-
ClientProperties.REQUEST_ENTITY_PROCESSING, RequestEntityProcessing.class);
40-
41-
final Boolean expectContinueActivated = request.resolveProperty(
42-
ClientProperties.EXPECT_100_CONTINUE, Boolean.class);
43-
final Long expectContinueSizeThreshold = request.resolveProperty(
44-
ClientProperties.EXPECT_100_CONTINUE_THRESHOLD_SIZE,
45-
ClientProperties.DEFAULT_EXPECT_100_CONTINUE_THRESHOLD_SIZE);
46-
45+
final RequestEntityProcessing entityProcessing = requestConfiguration.requestEntityProcessing(request);
46+
final Boolean expectContinueActivated = requestConfiguration.expect100Continue(request);
47+
final long expectContinueSizeThreshold = requestConfiguration.expect100ContinueThreshold(request);
4748
final boolean allowStreaming = length > expectContinueSizeThreshold
4849
|| entityProcessing == RequestEntityProcessing.CHUNKED;
4950

connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/JerseyClientHandler.java

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import jakarta.ws.rs.core.MultivaluedMap;
3232
import jakarta.ws.rs.core.Response;
3333

34-
import org.glassfish.jersey.client.ClientProperties;
3534
import org.glassfish.jersey.client.ClientRequest;
3635
import org.glassfish.jersey.client.ClientResponse;
3736
import org.glassfish.jersey.http.HttpHeaders;
@@ -56,37 +55,35 @@
5655
*/
5756
class JerseyClientHandler extends SimpleChannelInboundHandler<HttpObject> {
5857

59-
private static final int DEFAULT_MAX_REDIRECTS = 5;
60-
6158
// Modified only by the same thread. No need to synchronize it.
6259
private final Set<URI> redirectUriHistory;
6360
private final ClientRequest jerseyRequest;
6461
private final CompletableFuture<ClientResponse> responseAvailable;
6562
private final CompletableFuture<?> responseDone;
66-
private final boolean followRedirects;
67-
private final int maxRedirects;
6863
private final NettyConnector connector;
6964
private final NettyHttpRedirectController redirectController;
65+
private final NettyConnectorProvider.Config.RW requestConfiguration;
7066

7167
private NettyInputStream nis;
7268
private ClientResponse jerseyResponse;
7369

7470
private boolean readTimedOut;
7571

7672
JerseyClientHandler(ClientRequest request, CompletableFuture<ClientResponse> responseAvailable,
77-
CompletableFuture<?> responseDone, Set<URI> redirectUriHistory, NettyConnector connector) {
73+
CompletableFuture<?> responseDone, Set<URI> redirectUriHistory, NettyConnector connector,
74+
NettyConnectorProvider.Config.RW requestConfiguration) {
7875
this.redirectUriHistory = redirectUriHistory;
7976
this.jerseyRequest = request;
8077
this.responseAvailable = responseAvailable;
8178
this.responseDone = responseDone;
82-
// Follow redirects by default
83-
this.followRedirects = jerseyRequest.resolveProperty(ClientProperties.FOLLOW_REDIRECTS, true);
84-
this.maxRedirects = jerseyRequest.resolveProperty(NettyClientProperties.MAX_REDIRECTS, DEFAULT_MAX_REDIRECTS);
79+
this.requestConfiguration = requestConfiguration;
8580
this.connector = connector;
81+
// Follow redirects by default
82+
requestConfiguration.followRedirects(jerseyRequest);
83+
requestConfiguration.maxRedirects(jerseyRequest);
8684

87-
final NettyHttpRedirectController customRedirectController = jerseyRequest
88-
.resolveProperty(NettyClientProperties.HTTP_REDIRECT_CONTROLLER, NettyHttpRedirectController.class);
89-
this.redirectController = customRedirectController == null ? new NettyHttpRedirectController() : customRedirectController;
85+
this.redirectController = requestConfiguration.redirectController(jerseyRequest);
86+
this.redirectController.init(requestConfiguration);
9087
}
9188

9289
@Override
@@ -112,7 +109,7 @@ protected void notifyResponse(ChannelHandlerContext ctx) {
112109
ClientResponse cr = jerseyResponse;
113110
jerseyResponse = null;
114111
int responseStatus = cr.getStatus();
115-
if (followRedirects
112+
if (Boolean.TRUE.equals(requestConfiguration.followRedirects())
116113
&& (responseStatus == ResponseStatus.Redirect3xx.MOVED_PERMANENTLY_301.getStatusCode()
117114
|| responseStatus == ResponseStatus.Redirect3xx.FOUND_302.getStatusCode()
118115
|| responseStatus == ResponseStatus.Redirect3xx.SEE_OTHER_303.getStatusCode()
@@ -139,16 +136,17 @@ protected void notifyResponse(ChannelHandlerContext ctx) {
139136
// infinite loop detection
140137
responseAvailable.completeExceptionally(
141138
new RedirectException(LocalizationMessages.REDIRECT_INFINITE_LOOP()));
142-
} else if (redirectUriHistory.size() > maxRedirects) {
139+
} else if (redirectUriHistory.size() > requestConfiguration.maxRedirects.get()) {
143140
// maximal number of redirection
144-
responseAvailable.completeExceptionally(
145-
new RedirectException(LocalizationMessages.REDIRECT_LIMIT_REACHED(maxRedirects)));
141+
responseAvailable.completeExceptionally(new RedirectException(
142+
LocalizationMessages.REDIRECT_LIMIT_REACHED(requestConfiguration.maxRedirects.get())));
146143
} else {
147144
ClientRequest newReq = new ClientRequest(jerseyRequest);
148145
newReq.setUri(newUri);
149146
ctx.close();
150147
if (redirectController.prepareRedirect(newReq, cr)) {
151-
final NettyConnector newConnector = new NettyConnector(newReq.getClient());
148+
final NettyConnector newConnector =
149+
new NettyConnector(newReq.getClient(), connector.clientConfiguration);
152150
newConnector.execute(newReq, redirectUriHistory, new CompletableFuture<ClientResponse>() {
153151
@Override
154152
public boolean complete(ClientResponse value) {

connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/NettyClientProperties.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ public class NettyClientProperties {
7272
*/
7373
public static final String IDLE_CONNECTION_PRUNE_TIMEOUT = "jersey.config.client.idleConnectionPruneTimeout";
7474

75+
/**
76+
* Enable or disable the Netty logging by {@code LoggingHandler(Level.DEBUG)}. Disabled by default.
77+
*/
78+
public static final String LOGGING_ENABLED = "jersey.config.client.netty.loggingEnabled";
79+
7580
/**
7681
* <p>
7782
* This property determines the maximum number of idle connections that will be simultaneously kept alive, per destination.
@@ -157,7 +162,8 @@ public class NettyClientProperties {
157162
DEFAULT_HEADER_SIZE = 8192;
158163

159164
/**
160-
* Parameter which allows extending of the initial line length for the Netty connector
165+
* Parameter which allows extending of the first line length of the HTTP header for the Netty connector.
166+
* Taken from {@link io.netty.handler.codec.http.HttpClientCodec#HttpClientCodec(int, int, int)}.
161167
*
162168
* @since 2.44
163169
*/
@@ -166,12 +172,12 @@ public class NettyClientProperties {
166172

167173
/**
168174
* Default initial line length for Netty Connector.
169-
* Taken from {@link io.netty.handler.codec.http.HttpClientCodec#HttpClientCodec(int, int, int)}
175+
* Typically, set this to the same value as {@link #MAX_HEADER_SIZE}.
170176
*
171177
* @since 2.44
172178
*/
173179
public static final Integer
174-
DEFAULT_INITIAL_LINE_LENGTH = 4096;
180+
DEFAULT_INITIAL_LINE_LENGTH = 8192;
175181

176182
/**
177183
* Parameter which allows extending of the chunk size for the Netty connector
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (c) 2025 Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0, which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the
10+
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11+
* version 2 with the GNU Classpath Exception, which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
*/
16+
17+
package org.glassfish.jersey.netty.connector;
18+
19+
import org.glassfish.jersey.client.ClientRequest;
20+
21+
import java.net.URI;
22+
23+
/**
24+
* Adjustable connection pooling controller.
25+
*/
26+
public class NettyConnectionController {
27+
/**
28+
* Get the group of connections to be pooled, purged idle, and reused together.
29+
*
30+
* @param clientRequest the HTTP client request.
31+
* @param uri the uri for the HTTP client request.
32+
* @param hostName the hostname for the request. Can differ from the hostname in the uri based on other request attributes.
33+
* @param port the real port for the request. Can differ from the port in the uri based on other request attributes.
34+
* @return the group of connections identifier.
35+
*/
36+
public String getConnectionGroup(ClientRequest clientRequest, URI uri, String hostName, int port) {
37+
return uri.getScheme() + "://" + hostName + ":" + port;
38+
}
39+
}

0 commit comments

Comments
 (0)