Skip to content

Commit a8ae2fa

Browse files
authored
Avoid printing stack trace for ClosedChannelException in agent launch log (#10927)
1 parent 7455ceb commit a8ae2fa

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

core/src/main/java/hudson/slaves/SlaveComputer.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
import java.io.InputStream;
6767
import java.io.OutputStream;
6868
import java.io.PrintStream;
69+
import java.nio.channels.ClosedChannelException;
6970
import java.nio.charset.Charset;
7071
import java.security.Security;
7172
import java.util.ArrayList;
@@ -641,9 +642,11 @@ public void onClosed(Channel c, IOException cause) {
641642
// Orderly shutdown will have null exception
642643
if (cause != null) {
643644
offlineCause = new ChannelTermination(cause);
644-
Functions.printStackTrace(cause, taskListener.error("Connection terminated"));
645-
} else {
645+
}
646+
if (cause == null || cause instanceof ClosedChannelException) {
646647
taskListener.getLogger().println("Connection terminated");
648+
} else {
649+
Functions.printStackTrace(cause, taskListener.error("Connection terminated"));
647650
}
648651
closeChannel();
649652
try {

0 commit comments

Comments
 (0)