Search in sources :

Example 6 with ConnectionShutdownException

use of okhttp3.internal.http2.ConnectionShutdownException in project okhttp by square.

the class StreamAllocation method streamFailed.

public void streamFailed(IOException e) {
    Socket socket;
    boolean noNewStreams = false;
    synchronized (connectionPool) {
        if (e instanceof StreamResetException) {
            StreamResetException streamResetException = (StreamResetException) e;
            if (streamResetException.errorCode == ErrorCode.REFUSED_STREAM) {
                refusedStreamCount++;
            }
            // other errors must be retried on a new connection.
            if (streamResetException.errorCode != ErrorCode.REFUSED_STREAM || refusedStreamCount > 1) {
                noNewStreams = true;
                route = null;
            }
        } else if (connection != null && (!connection.isMultiplexed() || e instanceof ConnectionShutdownException)) {
            noNewStreams = true;
            // If this route hasn't completed a call, avoid it for new connections.
            if (connection.successCount == 0) {
                if (route != null && e != null) {
                    routeSelector.connectFailed(route, e);
                }
                route = null;
            }
        }
        socket = deallocate(noNewStreams, false, true);
    }
    closeQuietly(socket);
}
Also used : ConnectionShutdownException(okhttp3.internal.http2.ConnectionShutdownException) StreamResetException(okhttp3.internal.http2.StreamResetException) Socket(java.net.Socket)

Aggregations

IOException (java.io.IOException)4 InterruptedIOException (java.io.InterruptedIOException)4 InFrame (okhttp3.internal.http2.MockHttp2Peer.InFrame)4 Test (org.junit.Test)4 BufferedSink (okio.BufferedSink)3 ConnectionShutdownException (okhttp3.internal.http2.ConnectionShutdownException)2 HttpRetryException (java.net.HttpRetryException)1 ProtocolException (java.net.ProtocolException)1 Socket (java.net.Socket)1 Request (okhttp3.Request)1 Response (okhttp3.Response)1 RouteException (okhttp3.internal.connection.RouteException)1 StreamAllocation (okhttp3.internal.connection.StreamAllocation)1 StreamResetException (okhttp3.internal.http2.StreamResetException)1 Buffer (okio.Buffer)1