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

Read timeout in jetty http client tests #12184

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ public Request buildRequest(String method, URI uri, Map<String, String> headers)
request.agent("Jetty");

request.method(method);
request.timeout(READ_TIMEOUT.toMillis(), TimeUnit.MILLISECONDS);
if (uri.toString().contains("/read-timeout")) {
request.timeout(READ_TIMEOUT.toMillis(), TimeUnit.MILLISECONDS);
}

return request;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public abstract class AbstractJettyClient9Test extends AbstractHttpClientTest<Re
public void before() throws Exception {
// Start the main Jetty HttpClient and a https client
client = createStandardClient();
client.setConnectTimeout(5000L);
client.setConnectTimeout(CONNECTION_TIMEOUT.toMillis());
client.start();

SslContextFactory tlsCtx = new SslContextFactory();
Expand All @@ -55,13 +55,15 @@ protected void configure(HttpClientTestOptions.Builder optionsBuilder) {
@Override
public Request buildRequest(String method, URI uri, Map<String, String> headers) {
HttpClient theClient = uri.getScheme().equalsIgnoreCase("https") ? httpsClient : client;
Request request =
theClient
.newRequest(uri)
.method(method)
.agent("Jetty")
.timeout(5000L, TimeUnit.MILLISECONDS);
Request request = theClient.newRequest(uri).method(method).agent("Jetty");
headers.forEach(request::header);

if (uri.toString().contains("/read-timeout")) {
request.timeout(READ_TIMEOUT.toMillis(), TimeUnit.MILLISECONDS);
} else if (uri.toString().contains("192.0.2.1")) {
request.timeout(CONNECTION_TIMEOUT.toMillis(), TimeUnit.MILLISECONDS);
}

return request;
}

Expand Down
Loading