diff --git a/okhttp/src/main/java/com/squareup/okhttp/internal/spdy/SpdyConnection.java b/okhttp/src/main/java/com/squareup/okhttp/internal/spdy/SpdyConnection.java index 04bff0bad..3edb94ca5 100644 --- a/okhttp/src/main/java/com/squareup/okhttp/internal/spdy/SpdyConnection.java +++ b/okhttp/src/main/java/com/squareup/okhttp/internal/spdy/SpdyConnection.java @@ -575,7 +575,7 @@ public final class SpdyConnection implements Closeable { } connectionErrorCode = ErrorCode.NO_ERROR; streamErrorCode = ErrorCode.CANCEL; - } catch (IOException e) { + } catch (RuntimeException | IOException e) { connectionErrorCode = ErrorCode.PROTOCOL_ERROR; streamErrorCode = ErrorCode.PROTOCOL_ERROR; } finally { @@ -640,8 +640,11 @@ public final class SpdyConnection implements Closeable { @Override public void execute() { try { handler.receive(newStream); - } catch (IOException e) { - throw new RuntimeException(e); + } catch (RuntimeException | IOException e) { + try { + newStream.close(ErrorCode.PROTOCOL_ERROR); + } catch (IOException ignored) { + } } } });