Skip to content
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 @@ -11,8 +11,6 @@
import io.opentelemetry.instrumentation.testing.junit.http.HttpClientTestOptions;
import java.net.http.HttpClient;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.condition.DisabledForJreRange;
import org.junit.jupiter.api.condition.JRE;
import org.junit.jupiter.api.extension.RegisterExtension;

public abstract class JavaHttpClientTest extends AbstractJavaHttpClientTest {
Expand All @@ -34,7 +32,6 @@ protected void configureHttpClientBuilder(HttpClient.Builder httpClientBuilder)
}
}

@DisabledForJreRange(min = JRE.JAVA_25) // flaky on jdk25-ea
@Nested
static class Http2ClientTest extends JavaHttpClientTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import java.net.http.HttpClient;
import java.util.Collections;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.condition.DisabledForJreRange;
import org.junit.jupiter.api.condition.JRE;
import org.junit.jupiter.api.extension.RegisterExtension;

public abstract class JavaHttpClientTest extends AbstractJavaHttpClientTest {
Expand Down Expand Up @@ -41,7 +39,6 @@ protected void configureHttpClientBuilder(HttpClient.Builder httpClientBuilder)
}
}

@DisabledForJreRange(min = JRE.JAVA_25) // flaky on jdk25-ea
@Nested
static class Http2ClientTest extends JavaHttpClientTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ public HttpRequest buildRequest(String method, URI uri, Map<String, String> head
HttpRequest.Builder requestBuilder =
HttpRequest.newBuilder().uri(uri).method(method, HttpRequest.BodyPublishers.noBody());
headers.forEach(requestBuilder::header);
if (client.version() == HttpClient.Version.HTTP_2) {
// notify HttpClientTestServer that the request comes from java http client using http/2 so
// that the server can work around http/2 tests failing with java.io.IOException: RST_STREAM
// received
requestBuilder.header("java-http-client-http2", "true");
}
if (uri.toString().contains("/read-timeout")) {
requestBuilder.timeout(READ_TIMEOUT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,15 @@ protected void configure(ServerBuilder sb) throws Exception {
}
span.startSpan().end();

return delegate.serve(ctx, req);
// this header is set by java http client http/2 tests
// we delay the response a bit to ensure that client can send the full request before
// it receives the response
// this is a workaround for http/2 tests failing with java.io.IOException: RST_STREAM
// received
boolean delay = req.headers().get("java-http-client-http2") != null;

HttpResponse response = delegate.serve(ctx, req);
return delay ? HttpResponse.delayed(response, Duration.ofMillis(10)) : response;
})
.decorator(LoggingService.newDecorator());
}
Expand Down
Loading