mirror of
https://github.com/square/okhttp.git
synced 2026-01-17 08:42:25 +03:00
Fix MockWebServer with SPDY on Android.
Fix for issue #1552 Related to commitf78f74ffrom issue #1294 Before this change: SpdyConnection creates threads to handle the reading and writing. If those threads die from a RuntimeException it triggers Android's default UncaughtExceptionHandler, which kills the test process. Previously exceptions were being swallowed, but commitf78f74fcaused the exceptions to be propagated. This change adds extra handling for RuntimeException to stop them escaping.
This commit is contained in:
@@ -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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user