Skip to content

Commit

Permalink
[JENKINS-36871] Correctly detect and report the channel being closed …
Browse files Browse the repository at this point in the history
…for writing
  • Loading branch information
stephenc committed Aug 3, 2016
1 parent 6449a73 commit 8bb6354
Showing 1 changed file with 8 additions and 3 deletions.
Expand Up @@ -30,6 +30,7 @@
import hudson.remoting.Capability;
import hudson.remoting.Channel;
import hudson.remoting.ChannelBuilder;
import hudson.remoting.ChannelClosedException;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
Expand Down Expand Up @@ -288,10 +289,14 @@ public ByteBufferCommandTransport(Capability remoteCapability) {
@Override
protected void write(ByteBuffer header, ByteBuffer data) throws IOException {
if (isWriteOpen()) {
ChannelApplicationLayer.this.write(header);
ChannelApplicationLayer.this.write(data);
try {
ChannelApplicationLayer.this.write(header);
ChannelApplicationLayer.this.write(data);
} catch (ClosedChannelException e) {
throw new ChannelClosedException(e);
}
} else {
throw new ClosedChannelException();
throw new ChannelClosedException(new ClosedChannelException());
}
}

Expand Down

0 comments on commit 8bb6354

Please sign in to comment.