[
https://issues.apache.org/jira/browse/HTTPCLIENT-2249?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17636690#comment-17636690
]
Jens Schulze commented on HTTPCLIENT-2249:
------------------------------------------
Rerun my test now with 100 executions and no exception anymore (y)
And yes the commit may not be the culprit but it was introducing the exception.
So without the commit the underlying issue may never have been surfaced.
> Regression in HTTP client/core
> ------------------------------
>
> Key: HTTPCLIENT-2249
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2249
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Components: HttpClient (async)
> Affects Versions: 5.2
> Reporter: Jens Schulze
> Priority: Major
>
> This commit
> [https://github.com/apache/httpcomponents-core/commit/6741e3c555b96c4a64358adcb69aa0fddeb735b1]
> introduced a regression in either Core or Client.
> It leads to failing requests with "ProtocolException: Header `Host` is
> illegal" also the initiating request didn't included the mentioned header. I
> created a small reproducer:
> {code:java}
> package test.http.apachehttp;
> import java.util.concurrent.*;
> import org.apache.hc.client5.http.async.methods.SimpleHttpResponse;
> import org.apache.hc.client5.http.async.methods.SimpleResponseConsumer;
> import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
> import org.apache.hc.client5.http.impl.async.HttpAsyncClientBuilder;
> import org.apache.hc.core5.concurrent.FutureCallback;
> import org.apache.hc.core5.http.nio.AsyncRequestProducer;
> import org.apache.hc.core5.http.nio.support.AsyncRequestBuilder;
> public class HttpTest {
> // @Test
> public void reproduceHostError() {
> final Executor executor = new ForkJoinPool();
> final CloseableHttpAsyncClient client =
> HttpAsyncClientBuilder.create().build();
> client.start();
> AsyncRequestProducer p =
> AsyncRequestBuilder.get("https://google.com").build();
> final SimpleHttpResponse response1 = execute(executor, client,
> p).join();
> final SimpleHttpResponse response2 = execute(executor, client,
> p).join();
> final SimpleHttpResponse response3 = execute(executor, client,
> p).join();
> // final SimpleHttpResponse response4 = execute(executor,
> client, p).join();
> final int code = response1.getCode();
> }
> private CompletableFuture<SimpleHttpResponse> execute(Executor executor,
> CloseableHttpAsyncClient client,
> AsyncRequestProducer p) {
> final CompletableFuture<SimpleHttpResponse> apacheResponseFuture =
> new CompletableFuture<>();
> client.execute(p, SimpleResponseConsumer.create(), new
> FutureCallback<SimpleHttpResponse>() {
> @Override
> public void completed(SimpleHttpResponse result) {
> apacheResponseFuture.complete(result);
> }
> @Override
> public void failed(Exception ex) {
> apacheResponseFuture.completeExceptionally(ex);
> }
> @Override
> public void cancelled() {
> apacheResponseFuture.cancel(true);
> }
> });
> return apacheResponseFuture.thenApplyAsync(simpleHttpResponse1 ->
> simpleHttpResponse1, executor);
> }
> }
> {code}
> The 3rd request will fail with the mentioned ProtocolException.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]