Skip to content

Commit 559384a

Browse files
ahgittinAlex Heneveld
andauthored
restore the interrupt flag whenever we catch InterruptedException (#801)
Co-authored-by: Alex Heneveld <[email protected]>
1 parent 5674072 commit 559384a

File tree

4 files changed

+5
-0
lines changed

4 files changed

+5
-0
lines changed

src/main/java/net/schmizz/concurrent/Promise.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ public V tryRetrieve(long timeout, TimeUnit unit)
176176
}
177177
return val;
178178
} catch (InterruptedException ie) {
179+
Thread.currentThread().interrupt();
179180
throw chainer.chain(ie);
180181
} finally {
181182
lock.unlock();

src/main/java/net/schmizz/keepalive/KeepAlive.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ public void run() {
7575
TimeUnit.SECONDS.sleep(interval);
7676
}
7777
} catch (InterruptedException e) {
78+
// this is almost certainly a planned interruption, but even so, no harm in setting the interrupt flag
79+
Thread.currentThread().interrupt();
7880
log.trace("{} Interrupted while sleeping", getClass().getSimpleName());
7981
} catch (Exception e) {
8082
// If we weren't interrupted, kill the transport, then this exception was unexpected.

src/main/java/net/schmizz/sshj/connection/channel/ChannelInputStream.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public int read(byte[] b, int off, int len)
105105
try {
106106
buf.wait();
107107
} catch (InterruptedException e) {
108+
Thread.currentThread().interrupt();
108109
throw (IOException) new InterruptedIOException().initCause(e);
109110
}
110111
}

src/main/java/net/schmizz/sshj/connection/channel/Window.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public long awaitExpansion(long was) throws ConnectionException {
9393
throw new ConnectionException("Timeout when trying to expand the window size");
9494
}
9595
} catch (InterruptedException ie) {
96+
Thread.currentThread().interrupt();
9697
throw new ConnectionException(ie);
9798
}
9899
}

0 commit comments

Comments
 (0)