Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-57993] Avoid printing stack traces for some common agent conditions #4066

Merged
merged 2 commits into from
Jun 15, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions core/src/main/java/hudson/TcpSlaveAgentListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.SocketAddress;
import java.util.Arrays;
import jenkins.AgentProtocol;

import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
Expand Down Expand Up @@ -286,7 +286,11 @@ public void run() {
// try to clean up the socket
}
} catch (IOException e) {
LOGGER.log(Level.WARNING,"Connection #"+id+" failed",e);
if (e instanceof EOFException) {
LOGGER.log(Level.INFO, "Connection #{0} failed: {1}", new Object[] {id, e});
} else {
LOGGER.log(Level.WARNING, "Connection #" + id + " failed", e);
}
try {
s.close();
} catch (IOException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.jenkinsci.remoting.engine.JnlpConnectionState;

import java.io.IOException;
import java.nio.channels.ClosedChannelException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
Expand Down Expand Up @@ -181,7 +182,9 @@ public void afterChannel(@NonNull JnlpConnectionState event) {
public void channelClosed(@NonNull JnlpConnectionState event) {
final String nodeName = event.getProperty(JnlpConnectionState.CLIENT_NAME_KEY);
IOException cause = event.getCloseCause();
if (cause != null) {
if (cause instanceof ClosedChannelException) {
LOGGER.log(Level.INFO, "{0} for {1} terminated: {2}", new Object[] {Thread.currentThread().getName(), nodeName, cause});
} else if (cause != null) {
LOGGER.log(Level.WARNING, Thread.currentThread().getName() + " for " + nodeName + " terminated",
cause);
}
Expand Down