You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2020/03/07 10:12:09 UTC
[httpcomponents-client] branch master updated (f4fb8b5 -> ffa0530)
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git.
from f4fb8b5 Added Clirr API compatibility check
new 56ef8b8 Use try-with-resources in examples
new 99f7d2b Removed unnecessary BasicFuture wrapping
new ffa0530 Fix NPE for null HttpContext in minimal async clients
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../http/impl/async/CloseableHttpAsyncClient.java | 22 +---------------------
.../http/impl/async/MinimalH2AsyncClient.java | 2 +-
.../http/impl/async/MinimalHttpAsyncClient.java | 2 +-
.../hc/client5/http/examples/AsyncQuickStart.java | 5 +----
4 files changed, 4 insertions(+), 27 deletions(-)
[httpcomponents-client] 01/03: Use try-with-resources in examples
Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git
commit 56ef8b8642ab334cd0b35144c374295150af2bb2
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Mon Feb 24 12:07:55 2020 +0100
Use try-with-resources in examples
---
.../java/org/apache/hc/client5/http/examples/AsyncQuickStart.java | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncQuickStart.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncQuickStart.java
index e237a58..1d7d4fe 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncQuickStart.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncQuickStart.java
@@ -49,8 +49,7 @@ import org.apache.hc.core5.http.nio.support.AsyncRequestBuilder;
public class AsyncQuickStart {
public static void main (final String[] args) throws Exception {
- final CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
- try {
+ try (final CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault()) {
// Start the client
httpclient.start();
@@ -143,8 +142,6 @@ public class AsyncQuickStart {
});
latch2.await();
- } finally {
- httpclient.close();
}
}
[httpcomponents-client] 02/03: Removed unnecessary BasicFuture
wrapping
Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git
commit 99f7d2b710f210e030d52f871611fc1353bfbd30
Author: slisaasquatch <sl...@saasquat.ch>
AuthorDate: Fri Mar 6 09:12:33 2020 -0800
Removed unnecessary BasicFuture wrapping
---
.../http/impl/async/CloseableHttpAsyncClient.java | 22 +---------------------
1 file changed, 1 insertion(+), 21 deletions(-)
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/CloseableHttpAsyncClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/CloseableHttpAsyncClient.java
index ba0c21c..8abe0fc 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/CloseableHttpAsyncClient.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/CloseableHttpAsyncClient.java
@@ -36,7 +36,6 @@ import org.apache.hc.client5.http.async.methods.SimpleResponseConsumer;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.core5.annotation.Contract;
import org.apache.hc.core5.annotation.ThreadingBehavior;
-import org.apache.hc.core5.concurrent.BasicFuture;
import org.apache.hc.core5.concurrent.FutureCallback;
import org.apache.hc.core5.function.Supplier;
import org.apache.hc.core5.http.HttpHost;
@@ -122,26 +121,7 @@ public abstract class CloseableHttpAsyncClient implements HttpAsyncClient, Modal
final HttpContext context,
final FutureCallback<SimpleHttpResponse> callback) {
Args.notNull(request, "Request");
- final BasicFuture<SimpleHttpResponse> future = new BasicFuture<>(callback);
- execute(SimpleRequestProducer.create(request), SimpleResponseConsumer.create(), context, new FutureCallback<SimpleHttpResponse>() {
-
- @Override
- public void completed(final SimpleHttpResponse response) {
- future.completed(response);
- }
-
- @Override
- public void failed(final Exception ex) {
- future.failed(ex);
- }
-
- @Override
- public void cancelled() {
- future.cancel(true);
- }
-
- });
- return future;
+ return execute(SimpleRequestProducer.create(request), SimpleResponseConsumer.create(), context, callback);
}
public final Future<SimpleHttpResponse> execute(
[httpcomponents-client] 03/03: Fix NPE for null HttpContext in
minimal async clients
Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git
commit ffa0530bb2fb017e140e1be98754a6e1d25b905e
Author: slisaasquatch <sl...@saasquat.ch>
AuthorDate: Fri Mar 6 11:31:42 2020 -0800
Fix NPE for null HttpContext in minimal async clients
---
.../org/apache/hc/client5/http/impl/async/MinimalH2AsyncClient.java | 2 +-
.../org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalH2AsyncClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalH2AsyncClient.java
index bd4a35d..dc23b62 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalH2AsyncClient.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalH2AsyncClient.java
@@ -136,7 +136,7 @@ public final class MinimalH2AsyncClient extends AbstractMinimalHttpAsyncClientBa
final HttpContext context) {
ensureRunning();
final ComplexCancellable cancellable = new ComplexCancellable();
- final HttpClientContext clientContext = HttpClientContext.adapt(context);
+ final HttpClientContext clientContext = context != null ? HttpClientContext.adapt(context) : HttpClientContext.create();
try {
exchangeHandler.produceRequest(new RequestChannel() {
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java
index 65af820..d4e95d2 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java
@@ -248,7 +248,7 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient
final HttpContext context) {
ensureRunning();
final ComplexCancellable cancellable = new ComplexCancellable();
- final HttpClientContext clientContext = HttpClientContext.adapt(context);
+ final HttpClientContext clientContext = context != null ? HttpClientContext.adapt(context) : HttpClientContext.create();
try {
exchangeHandler.produceRequest(new RequestChannel() {