mirror of
https://github.com/square/okhttp.git
synced 2026-01-18 20:40:58 +03:00
Don't do I/O if the thread is interrupted.
(cherry picked from commit 664b65d18e)
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
package com.squareup.okhttp.internal.okio;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@@ -47,8 +48,11 @@ public class Deadline {
|
||||
return System.nanoTime() - deadlineNanos >= 0; // Subtract to avoid overflow!
|
||||
}
|
||||
|
||||
public void throwIfReached() throws IOException {
|
||||
public final void throwIfReached() throws IOException {
|
||||
// TODO: a more catchable exception type?
|
||||
if (reached()) throw new IOException("Deadline reached");
|
||||
|
||||
// If the thread is interrupted, do not proceed with further I/O.
|
||||
if (Thread.interrupted()) throw new InterruptedIOException();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user