diff --git a/src/main/java/org/jenkinsci/remoting/nio/FifoBuffer.java b/src/main/java/org/jenkinsci/remoting/nio/FifoBuffer.java index 27023455d..0952066a1 100644 --- a/src/main/java/org/jenkinsci/remoting/nio/FifoBuffer.java +++ b/src/main/java/org/jenkinsci/remoting/nio/FifoBuffer.java @@ -332,8 +332,12 @@ public void write(byte[] buf, int start, int len) throws InterruptedException, I int chunk; synchronized (lock) { - while ((chunk = Math.min(len,writable()))==0) + while ((chunk = Math.min(len,writable()))==0) { + if (closed) + throw new IOException("closed during write operation"); + lock.wait(100); + } w.write(buf, start, chunk);