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 2016/12/17 11:36:34 UTC
svn commit: r1774744 - in /httpcomponents/httpcore/trunk:
httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientPushHttp2StreamHandler.java
httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/BasicAsyncPushHandler.java
Author: olegk
Date: Sat Dec 17 11:36:34 2016
New Revision: 1774744
URL: http://svn.apache.org/viewvc?rev=1774744&view=rev
Log:
Improved exception handling by pushed streams
Modified:
httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientPushHttp2StreamHandler.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/BasicAsyncPushHandler.java
Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientPushHttp2StreamHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientPushHttp2StreamHandler.java?rev=1774744&r1=1774743&r2=1774744&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientPushHttp2StreamHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientPushHttp2StreamHandler.java Sat Dec 17 11:36:34 2016
@@ -42,9 +42,9 @@ import org.apache.hc.core5.http.Protocol
import org.apache.hc.core5.http.impl.BasicHttpConnectionMetrics;
import org.apache.hc.core5.http.impl.LazyEntityDetails;
import org.apache.hc.core5.http.impl.nio.MessageState;
-import org.apache.hc.core5.http.nio.HttpContextAware;
import org.apache.hc.core5.http.nio.AsyncPushConsumer;
import org.apache.hc.core5.http.nio.HandlerFactory;
+import org.apache.hc.core5.http.nio.HttpContextAware;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.apache.hc.core5.http2.H2ConnectionException;
@@ -180,6 +180,10 @@ class ClientPushHttp2StreamHandler imple
@Override
public void failed(final Exception cause) {
+ final AsyncPushConsumer localHandler = exchangeHandler;
+ if (localHandler != null) {
+ localHandler.failed(cause);
+ }
releaseResources();
}
Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/BasicAsyncPushHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/BasicAsyncPushHandler.java?rev=1774744&r1=1774743&r2=1774744&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/BasicAsyncPushHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/BasicAsyncPushHandler.java Sat Dec 17 11:36:34 2016
@@ -29,7 +29,6 @@ package org.apache.hc.core5.http.nio.sup
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.List;
-import java.util.concurrent.atomic.AtomicReference;
import org.apache.hc.core5.concurrent.FutureCallback;
import org.apache.hc.core5.http.EntityDetails;
@@ -49,17 +48,18 @@ import org.apache.hc.core5.util.Args;
public class BasicAsyncPushHandler<T> implements AsyncPushConsumer {
private final AsyncResponseConsumer<Message<HttpResponse, T>> responseConsumer;
- private final AtomicReference<Exception> exception;
public BasicAsyncPushHandler(final AsyncResponseConsumer<Message<HttpResponse, T>> responseConsumer) {
this.responseConsumer = Args.notNull(responseConsumer, "Response consumer");
- this.exception = new AtomicReference<>(null);
}
protected void handleResponse(
final HttpRequest promise, final Message<HttpResponse, T> responseMessage) throws IOException, HttpException {
}
+ protected void handleError(final HttpRequest promise, final Exception cause) {
+ }
+
@Override
public void consumePromise(
final HttpRequest promise,
@@ -77,8 +77,8 @@ public class BasicAsyncPushHandler<T> im
}
@Override
- public void failed(final Exception ex) {
- exception.compareAndSet(null, ex);
+ public void failed(final Exception cause) {
+ handleError(promise, cause);
releaseResources();
}
@@ -107,7 +107,7 @@ public class BasicAsyncPushHandler<T> im
@Override
public final void failed(final Exception cause) {
- exception.compareAndSet(null, cause);
+ responseConsumer.failed(cause);
releaseResources();
}