mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-06 15:20:54 +03:00
restore the interrupt flag whenever we catch InterruptedException (#801)
Co-authored-by: Alex Heneveld <alex@cloudsoft.io>
This commit is contained in:
@@ -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();
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user