restore the interrupt flag whenever we catch InterruptedException (#801)

Co-authored-by: Alex Heneveld <alex@cloudsoft.io>
This commit is contained in:
Alex Heneveld
2022-08-08 13:09:18 +01:00
committed by GitHub
parent 5674072666
commit 559384ac91
4 changed files with 5 additions and 0 deletions

View File

@@ -176,6 +176,7 @@ public class Promise<V, T extends Throwable> {
} }
return val; return val;
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
Thread.currentThread().interrupt();
throw chainer.chain(ie); throw chainer.chain(ie);
} finally { } finally {
lock.unlock(); lock.unlock();

View File

@@ -75,6 +75,8 @@ public abstract class KeepAlive extends Thread {
TimeUnit.SECONDS.sleep(interval); TimeUnit.SECONDS.sleep(interval);
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
// this is almost certainly a planned interruption, but even so, no harm in setting the interrupt flag
Thread.currentThread().interrupt();
log.trace("{} Interrupted while sleeping", getClass().getSimpleName()); log.trace("{} Interrupted while sleeping", getClass().getSimpleName());
} catch (Exception e) { } catch (Exception e) {
// If we weren't interrupted, kill the transport, then this exception was unexpected. // If we weren't interrupted, kill the transport, then this exception was unexpected.

View File

@@ -105,6 +105,7 @@ public final class ChannelInputStream
try { try {
buf.wait(); buf.wait();
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw (IOException) new InterruptedIOException().initCause(e); throw (IOException) new InterruptedIOException().initCause(e);
} }
} }

View File

@@ -93,6 +93,7 @@ public abstract class Window {
throw new ConnectionException("Timeout when trying to expand the window size"); throw new ConnectionException("Timeout when trying to expand the window size");
} }
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
Thread.currentThread().interrupt();
throw new ConnectionException(ie); throw new ConnectionException(ie);
} }
} }