Skip to content

Commit

Permalink
pass the context to client.execute() call in test
Browse files Browse the repository at this point in the history
In apache/httpcomponents-client@762b18f#diff-211fca6aa691ca5414d407b6c70c9b02e75873835bc84f00a96b21af0f86fb4fR321 the empty context creation was removed from the execute() method leading to NPEs in tests.
  • Loading branch information
kasmarian committed Oct 29, 2024
1 parent f728036 commit 46d93ef
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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.client5.http.protocol.HttpClientContext;
import org.apache.hc.core5.concurrent.FutureCallback;
import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.HttpHeaders;
Expand Down Expand Up @@ -55,7 +56,7 @@ protected ClassicHttpResponse sendAndReceive(@Nullable final String body) throws

AtomicReference<String> responseRef = new AtomicReference<>(null);
CountDownLatch latch = new CountDownLatch(1);
HttpResponse response = client.execute(SimpleRequestProducer.create(builder.build()), new LogbookHttpAsyncResponseConsumer<>(SimpleResponseConsumer.create()), getCallback(responseRef, latch)).get();
HttpResponse response = client.execute(SimpleRequestProducer.create(builder.build()), new LogbookHttpAsyncResponseConsumer<>(SimpleResponseConsumer.create()), HttpClientContext.create(), getCallback(responseRef, latch)).get();

BasicClassicHttpResponse httpResponse = new BasicClassicHttpResponse(response.getCode(), response.getReasonPhrase());
latch.await(5, SECONDS);
Expand Down

0 comments on commit 46d93ef

Please sign in to comment.