Skip to content

Commit

Permalink
Clean up a few plain e.printStackTrace() calls (#9742)
Browse files Browse the repository at this point in the history
Co-authored-by: Jesse Glick <[email protected]>
  • Loading branch information
Vlatombe and jglick authored Sep 19, 2024
1 parent 82dfb09 commit f9fef61
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public void run() {
new File(installationDir, "jenkins.exe"), "start", task, installationDir);
task.getLogger().println(r == 0 ? "Successfully started" : "start service failed. Exit code=" + r);
} catch (IOException | InterruptedException e) {
e.printStackTrace();
LOGGER.log(Level.WARNING, null, e);
}
}

Expand All @@ -241,7 +241,7 @@ private DefaultLogger createLogger() {
Jenkins.get().cleanUp();
System.exit(0);
} catch (InterruptedException e) {
e.printStackTrace();
LOGGER.log(Level.SEVERE, null, e);

Check warning on line 244 in core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 229-244 are not covered by tests
}
}
}.start();
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/model/AbstractItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ protected void renameTo(final String newName) throws IOException {
Util.deleteRecursive(oldRoot);
} catch (IOException e) {
// but ignore the error, since we expect that
e.printStackTrace();
LOGGER.log(Level.WARNING, "Ignoring IOException while deleting", e);

Check warning on line 437 in core/src/main/java/hudson/model/AbstractItem.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 437 is not covered by tests
}
}

Expand Down
15 changes: 12 additions & 3 deletions core/src/main/java/hudson/model/ViewJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,23 @@ private boolean terminating() {
@Override
public void run() {
while (!terminating()) {
String jobName = null;
try {
getNext()._reload();
var next = getNext();
jobName = next.getFullName();
next._reload();
jobName = null;
} catch (InterruptedException e) {
// treat this as a death signal
return;
} catch (Throwable t) {
} catch (Exception e) {
// otherwise ignore any error
t.printStackTrace();
if (jobName != null) {
var finalJobName = jobName;
LOGGER.log(Level.WARNING, e, () -> "Failed to reload job " + finalJobName);
} else {
LOGGER.log(Level.WARNING, e, () -> "Failed to obtain next job in the reload queue");

Check warning on line 254 in core/src/main/java/hudson/model/ViewJob.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 239-254 are not covered by tests
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/jenkins/model/Jenkins.java
Original file line number Diff line number Diff line change
Expand Up @@ -5631,7 +5631,7 @@ private static void computeVersion(ServletContext context) {
if (is != null)
props.load(is);
} catch (IOException e) {
e.printStackTrace(); // if the version properties is missing, that's OK.
LOGGER.log(Level.WARNING, e, () -> "Failed to load jenkins-version.properties");

Check warning on line 5634 in core/src/main/java/jenkins/model/Jenkins.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 5634 is not covered by tests
}
String ver = props.getProperty("version");
if (ver == null) ver = UNCOMPUTED_VERSION;
Expand Down

0 comments on commit f9fef61

Please sign in to comment.