Skip to content

Commit

Permalink
Tone down logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Jul 27, 2023
1 parent ce9adda commit bfaf04b
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
import java.util.logging.Logger;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.remoting.ChannelClosedException;
import java.io.EOFException;
import java.nio.channels.ClosedChannelException;
import java.util.stream.Stream;
import jenkins.MasterToSlaveFileCallable;
import jenkins.model.Jenkins;
import jenkins.security.MasterToSlaveCallable;
Expand Down Expand Up @@ -576,6 +580,21 @@ private static class StartWatching extends MasterToSlaveFileCallable<Void> {

}

// TODO https://github.com/jenkinsci/remoting/pull/657

Check warning on line 583 in src/main/java/org/jenkinsci/plugins/durabletask/FileMonitoringTask.java

View check run for this annotation

ci.jenkins.io / Open Tasks Scanner

TODO

private static boolean isClosedChannelException(Throwable t) {
if (t instanceof ClosedChannelException) {

Check warning on line 585 in src/main/java/org/jenkinsci/plugins/durabletask/FileMonitoringTask.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 585 is only partially covered, 2 branches are missing
return true;

Check warning on line 586 in src/main/java/org/jenkinsci/plugins/durabletask/FileMonitoringTask.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 586 is not covered by tests
} else if (t instanceof ChannelClosedException) {

Check warning on line 587 in src/main/java/org/jenkinsci/plugins/durabletask/FileMonitoringTask.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 587 is only partially covered, 2 branches are missing
return true;

Check warning on line 588 in src/main/java/org/jenkinsci/plugins/durabletask/FileMonitoringTask.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 588 is not covered by tests
} else if (t instanceof EOFException) {

Check warning on line 589 in src/main/java/org/jenkinsci/plugins/durabletask/FileMonitoringTask.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 589 is only partially covered, 2 branches are missing
return true;

Check warning on line 590 in src/main/java/org/jenkinsci/plugins/durabletask/FileMonitoringTask.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 590 is not covered by tests
} else if (t == null) {

Check warning on line 591 in src/main/java/org/jenkinsci/plugins/durabletask/FileMonitoringTask.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 591 is only partially covered, 2 branches are missing
return false;

Check warning on line 592 in src/main/java/org/jenkinsci/plugins/durabletask/FileMonitoringTask.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 592 is not covered by tests
} else {
return isClosedChannelException(t.getCause()) || Stream.of(t.getSuppressed()).anyMatch(FileMonitoringTask::isClosedChannelException);

Check warning on line 594 in src/main/java/org/jenkinsci/plugins/durabletask/FileMonitoringTask.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 594 is only partially covered, 4 branches are missing
}
}

private static class Watcher implements Runnable {

private final FileMonitoringController controller;
Expand Down Expand Up @@ -638,7 +657,11 @@ private static class Watcher implements Runnable {
}
} catch (Exception x) {
// note that LOGGER here is going to the agent log, not master log
LOGGER.log(Level.WARNING, "giving up on watching " + controller.controlDir, x);
if (isClosedChannelException(x)) {

Check warning on line 660 in src/main/java/org/jenkinsci/plugins/durabletask/FileMonitoringTask.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 660 is only partially covered, 2 branches are missing
LOGGER.warning(() -> this + " giving up on watching " + controller.controlDir);

Check warning on line 661 in src/main/java/org/jenkinsci/plugins/durabletask/FileMonitoringTask.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 661 is not covered by tests
} else {
LOGGER.log(Level.WARNING, this + " giving up on watching " + controller.controlDir, x);

Check warning on line 663 in src/main/java/org/jenkinsci/plugins/durabletask/FileMonitoringTask.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 663 is not covered by tests
}
// Typically this will have been inside Handler.output, e.g.:
// hudson.remoting.ChannelClosedException: channel is already closed
// at hudson.remoting.Channel.send(Channel.java:667)
Expand Down

0 comments on commit bfaf04b

Please sign in to comment.