Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #12266 - InvocationType improvements and cleanups. #12596

Open
wants to merge 21 commits into
base: jetty-12.1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift click to select a range
1345a6f
Issue #12266 - InvocationType improvements and cleanups.
sbordet Nov 29, 2024
6ff2e58
Renamed HttpClient.getTransport() to getHttpClientTransport().
sbordet Nov 29, 2024
751c886
Fixed FCGI parsing: onResponseHeaders() was called multiple times in …
sbordet Nov 30, 2024
5352c05
Reverted theh renaming of `HttpClient.getTransport()`.
sbordet Dec 1, 2024
4d4c88a
Fixed race condition when notifying HTTP/2 `HeadersFrame`s.
sbordet Dec 2, 2024
a3b728e
Merged branch 'jetty-12.1.x' into 'fix/jetty-12.1.x/client-invocation…
sbordet Dec 2, 2024
fa7c4a4
Fixed IteratingCallback tests due to changes in toString().
sbordet Dec 2, 2024
78d8a66
Reverted "optimization" in `HttpReceiver.responseHeaders()`.
sbordet Dec 3, 2024
b0b60d1
Reverted another "optimization" in `HttpReceiver.responseHeaders()`.
sbordet Dec 3, 2024
3438462
Merged branch 'jetty-12.1.x' into 'fix/jetty-12.1.x/client-invocation…
sbordet Dec 8, 2024
f7788da
Merged branch 'jetty-12.1.x' into 'fix/jetty-12.1.x/client-invocation…
sbordet Dec 16, 2024
8e036dd
Merged branch 'jetty-12.1.x' into 'fix/jetty-12.1.x/client-invocation…
sbordet Dec 17, 2024
630d5c5
Fixed HTTP/2 serialization in HttpReceiverOverHTTP2.
sbordet Dec 20, 2024
7947030
Fixed tests.
sbordet Dec 20, 2024
dbc7da7
Fixed tests.
sbordet Dec 20, 2024
21d4dfc
Fixed tests.
sbordet Dec 23, 2024
2836d34
Merged branch 'jetty-12.1.x' into 'fix/jetty-12.1.x/client-invocation…
sbordet Dec 23, 2024
ae197ab
Fixed flaky tests.
sbordet Dec 24, 2024
d4da186
Fixed tests.
sbordet Dec 25, 2024
39d7823
Fixed tests.
sbordet Dec 26, 2024
6dbeb96
Fixed handling of HTTP upgrade in CoreClientUpgradeRequest.
sbordet Dec 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reverted theh renaming of HttpClient.getTransport().
Signed-off-by: Simone Bordet <[email protected]>
  • Loading branch information
sbordet committed Dec 1, 2024
commit 5352c0598ded15a98ea2a4c679273c085a6d16df
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 1070,7 @@ public void setConnectionPool() throws Exception
// the transport supports multiplexing requests on the same connection.
int maxRequestsPerConnection = 1;

HttpClientTransport transport = httpClient.getHttpClientTransport();
HttpClientTransport transport = httpClient.getTransport();

// Set the ConnectionPool.Factory using a lambda.
transport.setConnectionPoolFactory(destination ->
Expand All @@ -1087,7 1087,7 @@ public void preCreateConnections() throws Exception
httpClient.start();

// For HTTP/1.1, you need to explicitly configure to initialize connections.
if (httpClient.getHttpClientTransport() instanceof HttpClientTransportOverHTTP http1)
if (httpClient.getTransport() instanceof HttpClientTransportOverHTTP http1)
http1.setInitializeConnections(true);

// Create a dummy request to the server you want to pre-create connections to.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 157,7 @@ public HttpClient(HttpClientTransport transport)
installBean(decoderFactories);
}

/**
* @deprecated use {@link #getHttpClientTransport()} instead
*/
@Deprecated(forRemoval = true, since = "12.1.0")
public HttpClientTransport getTransport()
{
return getHttpClientTransport();
}

/**
* @return the {@link HttpClientTransport} associated with this {@code HttpClient}.
*/
public HttpClientTransport getHttpClientTransport()
{
return transport;
}
Expand Down Expand Up @@ -463,7 451,7 @@ private HttpRequest newHttpRequest(HttpConversation conversation, URI uri)

public Destination resolveDestination(Request request)
{
HttpClientTransport transport = getHttpClientTransport();
HttpClientTransport transport = getTransport();
Origin origin = transport.newOrigin(request);
Destination destination = resolveDestination(origin);
if (LOG.isDebugEnabled())
Expand Down Expand Up @@ -500,7 488,7 @@ public Destination resolveDestination(Origin origin)
{
if (v == null || v.stale())
{
HttpDestination newDestination = (HttpDestination)getHttpClientTransport().newDestination(k);
HttpDestination newDestination = (HttpDestination)getTransport().newDestination(k);
// Start the destination before it's published to other threads.
addManaged(newDestination);
if (destinationSweeper != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 53,7 @@ public org.eclipse.jetty.io.Connection newConnection(EndPoint endPoint, Map<Stri
HttpClient httpClient = (HttpClient)context.get(ClientConnectionFactory.CLIENT_CONTEXT_KEY);
HttpConnectionOverHTTP connection = new HttpConnectionOverHTTP(endPoint, context);
connection.setInitialize(isInitializeConnections());
connection.setInvocationType(httpClient.getHttpClientTransport().getInvocationType());
connection.setInvocationType(httpClient.getTransport().getInvocationType());
return customize(connection, context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 92,7 @@ public HttpDestination(HttpClient client, Origin origin)
host = ":" port;
hostField = new HttpField(HttpHeader.HOST, host);

ClientConnectionFactory connectionFactory = client.getHttpClientTransport();
ClientConnectionFactory connectionFactory = client.getTransport();
boolean intrinsicallySecure = origin.getTransport().isIntrinsicallySecure();

ProxyConfiguration proxyConfig = client.getProxyConfiguration();
Expand Down Expand Up @@ -186,7 186,7 @@ protected void doStop() throws Exception

protected ConnectionPool newConnectionPool(HttpClient client)
{
return client.getHttpClientTransport().getConnectionPoolFactory().newConnectionPool(this);
return client.getTransport().getConnectionPoolFactory().newConnectionPool(this);
}

protected Queue<HttpExchange> newExchangeQueue(HttpClient client)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 63,7 @@ public HttpReceiverOverHTTP(HttpChannelOverHTTP channel)
super(channel);
HttpClient httpClient = channel.getHttpDestination().getHttpClient();
parser = new HttpParser(this, httpClient.getMaxResponseHeadersSize(), httpClient.getHttpCompliance());
HttpClientTransport transport = httpClient.getHttpClientTransport();
HttpClientTransport transport = httpClient.getTransport();
if (transport instanceof HttpClientTransportOverHTTP httpTransport)
{
parser.setHeaderCacheSize(httpTransport.getHeaderCacheSize());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 65,7 @@ public void upgrade(Response response, EndPoint endPoint, Callback callback)
if (response.getHeaders().contains(HttpHeader.UPGRADE, protocol))
{
HttpClient httpClient = destination.getHttpClient();
HttpClientTransport transport = httpClient.getHttpClientTransport();
HttpClientTransport transport = httpClient.getTransport();
if (transport instanceof HttpClientTransportDynamic dynamic)
{
Origin origin = destination.getOrigin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 95,8 @@ protected void sendHeaders(HttpExchange exchange, ByteBuffer contentBuffer, bool
}

// Give a chance to the transport implementation to customize the FastCGI headers
HttpClientTransportOverFCGI transport = (HttpClientTransportOverFCGI)getHttpChannel().getHttpDestination().getHttpClient().getHttpClientTransport();
HttpClient httpClient = getHttpChannel().getHttpDestination().getHttpClient();
HttpClientTransportOverFCGI transport = (HttpClientTransportOverFCGI)httpClient.getTransport();
transport.customize(request, fcgiHeaders);

ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 97,7 @@ protected Connection newConnection(Destination destination, Session session, HTT
{
HttpClient httpClient = (HttpClient)context.get(ClientConnectionFactory.CLIENT_CONTEXT_KEY);
HttpConnectionOverHTTP2 result = new HttpConnectionOverHTTP2(destination, session, connection);
result.setInvocationType(httpClient.getHttpClientTransport().getInvocationType());
result.setInvocationType(httpClient.getTransport().getInvocationType());
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 380,7 @@ public boolean handle(Request request, org.eclipse.jetty.server.Response respons

httpClient.setMaxConnectionsPerDestination(32768);
httpClient.setMaxRequestsQueuedPerDestination(1024 * 1024);
httpClient.getHttpClientTransport().setConnectionPoolFactory(destination ->
httpClient.getTransport().setConnectionPoolFactory(destination ->
{
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 48,7 @@ public void testPreCreateConnections(Transport transport) throws Exception
startClient(transport);
client.setMaxConnectionsPerDestination(maxConnectionsPerDestination);
if (transport == Transport.HTTPS)
((HttpClientTransportOverHTTP)client.getHttpClientTransport()).setInitializeConnections(true);
((HttpClientTransportOverHTTP)client.getTransport()).setInitializeConnections(true);

var request = client.newRequest(newURI(transport));
Destination destination = client.resolveDestination(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 81,7 @@ public void testDefaultTransport() throws Exception
Destination destination = destinations.get(0);
assertThat(destination.getOrigin().getTransport(), sameInstance(Transport.TCP_IP));

HttpClientTransportOverHTTP httpClientTransport = (HttpClientTransportOverHTTP)httpClient.getHttpClientTransport();
HttpClientTransportOverHTTP httpClientTransport = (HttpClientTransportOverHTTP)httpClient.getTransport();
int networkConnections = httpClientTransport.getClientConnector().getSelectorManager().getTotalKeys();
assertThat(networkConnections, is(1));
}
Expand Down Expand Up @@ -117,7 117,7 @@ public void testMemoryTransport() throws Exception

assertThat(response.getStatus(), is(HttpStatus.OK_200));

HttpClientTransportOverHTTP httpClientTransport = (HttpClientTransportOverHTTP)httpClient.getHttpClientTransport();
HttpClientTransportOverHTTP httpClientTransport = (HttpClientTransportOverHTTP)httpClient.getTransport();
int networkConnections = httpClientTransport.getClientConnector().getSelectorManager().getTotalKeys();
assertThat(networkConnections, is(0));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 96,7 @@ public void testDefaultTransport() throws Exception
Destination destination = destinations.get(0);
assertThat(destination.getOrigin().getTransport(), sameInstance(Transport.TCP_IP));

HttpClientTransportOverHTTP2 httpClientTransport = (HttpClientTransportOverHTTP2)httpClient.getHttpClientTransport();
HttpClientTransportOverHTTP2 httpClientTransport = (HttpClientTransportOverHTTP2)httpClient.getTransport();
int networkConnections = httpClientTransport.getHTTP2Client().getClientConnector().getSelectorManager().getTotalKeys();
assertThat(networkConnections, is(1));
}
Expand Down Expand Up @@ -132,7 132,7 @@ public void testMemoryTransport() throws Exception

assertThat(response.getStatus(), is(HttpStatus.OK_200));

HttpClientTransportOverHTTP2 httpClientTransport = (HttpClientTransportOverHTTP2)httpClient.getHttpClientTransport();
HttpClientTransportOverHTTP2 httpClientTransport = (HttpClientTransportOverHTTP2)httpClient.getTransport();
int networkConnections = httpClientTransport.getHTTP2Client().getClientConnector().getSelectorManager().getTotalKeys();
assertThat(networkConnections, is(0));
}
Expand Down Expand Up @@ -201,7 201,7 @@ public void testQUICTransportWithH2(WorkDir workDir) throws Exception

SslContextFactory.Client sslClient = new SslContextFactory.Client(true);
httpClient.setSslContextFactory(sslClient);
HttpClientTransportOverHTTP2 httpClientTransport = (HttpClientTransportOverHTTP2)httpClient.getHttpClientTransport();
HttpClientTransportOverHTTP2 httpClientTransport = (HttpClientTransportOverHTTP2)httpClient.getTransport();
// ALPN is negotiated by QUIC.
httpClientTransport.setUseALPN(false);
ClientQuicConfiguration clientQuicConfig = new ClientQuicConfiguration(sslClient, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 108,7 @@ public void testDefaultTransport() throws Exception
transport = wrapper.unwrap();
assertThat(transport, sameInstance(Transport.UDP_IP));

HttpClientTransportOverHTTP3 httpClientTransport = (HttpClientTransportOverHTTP3)httpClient.getHttpClientTransport();
HttpClientTransportOverHTTP3 httpClientTransport = (HttpClientTransportOverHTTP3)httpClient.getTransport();
int networkConnections = httpClientTransport.getHTTP3Client().getClientConnector().getSelectorManager().getTotalKeys();
assertThat(networkConnections, is(1));
}
Expand Down Expand Up @@ -148,7 148,7 @@ public void testMemoryTransport() throws Exception

assertThat(response.getStatus(), is(HttpStatus.OK_200));

HttpClientTransportOverHTTP3 httpClientTransport = (HttpClientTransportOverHTTP3)httpClient.getHttpClientTransport();
HttpClientTransportOverHTTP3 httpClientTransport = (HttpClientTransportOverHTTP3)httpClient.getTransport();
int networkConnections = httpClientTransport.getHTTP3Client().getClientConnector().getSelectorManager().getTotalKeys();
assertThat(networkConnections, is(0));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 1253,7 @@ public boolean handle(Request request, org.eclipse.jetty.server.Response respons
// - the connection can be used by two concurrent requests;
// - the connection is pre-created.
client.setMaxConnectionsPerDestination(1);
client.getHttpClientTransport().setConnectionPoolFactory(destination ->
client.getTransport().setConnectionPoolFactory(destination ->
{
MultiplexConnectionPool pool = new MultiplexConnectionPool(destination, 1, 2);
LifeCycle.start(pool);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 66,7 @@ public boolean handle(Request request, Response response, Callback callback)

int maxConnections = 3;
CompletableFuture<Void> setup = new CompletableFuture<>();
client.getHttpClientTransport().setConnectionPoolFactory(destination ->
client.getTransport().setConnectionPoolFactory(destination ->
{
RoundRobinConnectionPool pool = new RoundRobinConnectionPool(destination, maxConnections);
LifeCycle.start(pool);
Expand Down Expand Up @@ -146,7 146,7 @@ public boolean handle(Request request, Response response, Callback callback)
});

CompletableFuture<Void> setup = new CompletableFuture<>();
client.getHttpClientTransport().setConnectionPoolFactory(destination ->
client.getTransport().setConnectionPoolFactory(destination ->
{
RoundRobinConnectionPool pool = new RoundRobinConnectionPool(destination, maxConnections);
LifeCycle.start(pool);
Expand Down Expand Up @@ -226,7 226,7 @@ public boolean handle(Request request, Response response, Callback callback)
});
if (transport == Transport.H3)
((QuicServerConnector)connector).getQuicConfiguration().setMaxBidirectionalRemoteStreams(maxUsage);
client.getHttpClientTransport().setConnectionPoolFactory(destination ->
client.getTransport().setConnectionPoolFactory(destination ->
{
RoundRobinConnectionPool pool = new RoundRobinConnectionPool(destination, maxConnections, maxMultiplex);
pool.setMaxUsage(maxUsage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 87,7 @@ private void testTLSWrapFailure(Transport transport, TLSHandshakeAction action,
{
start(transport, new EmptyServerHandler());
client.stop();
client = new HttpClient(client.getHttpClientTransport())
client = new HttpClient(client.getTransport())
{
@Override
public ClientConnectionFactory newSslClientConnectionFactory(SslContextFactory.Client sslContextFactory, ClientConnectionFactory connectionFactory)
Expand Down Expand Up @@ -163,7 163,7 @@ private void testTLSUnwrapFailure(Transport transport, TLSHandshakeAction action
{
start(transport, new EmptyServerHandler());
client.stop();
client = new HttpClient(client.getHttpClientTransport())
client = new HttpClient(client.getTransport())
{
@Override
public ClientConnectionFactory newSslClientConnectionFactory(SslContextFactory.Client sslContextFactory, ClientConnectionFactory connectionFactory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 116,7 @@ public boolean handle(Request request, Response response, Callback callback) thr
vtp.setName("green-");
executor.setVirtualThreadsExecutor(vtp);
Invocable.InvocationType invocationType = blocking ? Invocable.InvocationType.BLOCKING : Invocable.InvocationType.NON_BLOCKING;
client.getHttpClientTransport().setInvocationType(invocationType);
client.getTransport().setInvocationType(invocationType);
client.start();

for (int i = 0; i < 2; i)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 609,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response)
}
}
});
((HttpClientTransportOverHTTP2)client.getHttpClientTransport()).getHTTP2Client().setInitialStreamRecvWindow(FlowControlStrategy.DEFAULT_WINDOW_SIZE);
((HttpClientTransportOverHTTP2)client.getTransport()).getHTTP2Client().setInitialStreamRecvWindow(FlowControlStrategy.DEFAULT_WINDOW_SIZE);

// Setup the client to read slower than the min data rate.
BlockingQueue<Object> objects = new LinkedBlockingQueue<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 609,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response)
}
}
});
((HttpClientTransportOverHTTP2)client.getHttpClientTransport()).getHTTP2Client().setInitialStreamRecvWindow(FlowControlStrategy.DEFAULT_WINDOW_SIZE);
((HttpClientTransportOverHTTP2)client.getTransport()).getHTTP2Client().setInitialStreamRecvWindow(FlowControlStrategy.DEFAULT_WINDOW_SIZE);

// Setup the client to read slower than the min data rate.
BlockingQueue<Object> objects = new LinkedBlockingQueue<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 592,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response)
}
}
});
((HttpClientTransportOverHTTP2)client.getHttpClientTransport()).getHTTP2Client().setInitialStreamRecvWindow(FlowControlStrategy.DEFAULT_WINDOW_SIZE);
((HttpClientTransportOverHTTP2)client.getTransport()).getHTTP2Client().setInitialStreamRecvWindow(FlowControlStrategy.DEFAULT_WINDOW_SIZE);

// Setup the client to read slower than the min data rate.
BlockingQueue<Object> objects = new LinkedBlockingQueue<>();
Expand Down