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 @@ -29,6 +29,7 @@
import static org.apache.hc.core5.http.ContentType.TEXT_EVENT_STREAM;

import java.io.InterruptedIOException;
import java.net.SocketTimeoutException;
import java.net.URI;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -60,6 +61,7 @@
import org.apache.hc.core5.http.RequestNotExecutedException;
import org.apache.hc.core5.http.nio.AsyncEntityConsumer;
import org.apache.hc.core5.http.nio.AsyncResponseConsumer;
import org.apache.hc.core5.http2.H2StreamTimeoutException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -513,6 +515,8 @@ private void notifyClosedOnce() {

/**
* Returns {@code true} for failure types that are expected during cancel/close.
* Socket, connect and HTTP/2 stream timeouts are network failures and are never benign,
* even though they extend {@link InterruptedIOException}.
*
* @param ex the exception to inspect
* @return {@code true} if the exception represents a benign cancellation
Expand All @@ -521,6 +525,8 @@ private static boolean isBenignCancel(final Exception ex) {
return ex instanceof RequestNotExecutedException
|| ex instanceof ConnectionClosedException
|| ex instanceof CancellationException
|| ex instanceof InterruptedIOException;
|| ex instanceof InterruptedIOException
&& !(ex instanceof SocketTimeoutException)
&& !(ex instanceof H2StreamTimeoutException);
}
}
Loading
Loading