Skip to content

Commit

Permalink
Directly throw IOException (#700)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored Oct 27, 2023
1 parent b493ab7 commit 713e3b0
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions src/main/java/hudson/remoting/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ private static void closeWithLogOnly(Closeable stream, String name) {
}

@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "Parameter supplied by user / administrator.")
private Engine createEngine() {
private Engine createEngine() throws IOException {
LOGGER.log(Level.INFO, "Setting up agent: {0}", name);
Engine engine = new Engine(
new CuiListener(),
Expand Down Expand Up @@ -1033,18 +1033,10 @@ private Engine createEngine() {

// TODO: ideally logging should be initialized before the "Setting up agent" entry

Check warning on line 1034 in src/main/java/hudson/remoting/Launcher.java

View check run for this annotation

ci.jenkins.io / Open Tasks Scanner

TODO

NORMAL: ideally logging should be initialized before the "Setting up agent" entry
if (agentLog != null) {
try {
engine.setAgentLog(PathUtils.fileToPath(agentLog));
} catch (IOException ex) {
throw new IllegalStateException("Cannot retrieve custom log destination", ex);
}
engine.setAgentLog(PathUtils.fileToPath(agentLog));
}
if (loggingConfigFilePath != null) {
try {
engine.setLoggingConfigFile(PathUtils.fileToPath(loggingConfigFilePath));
} catch (IOException ex) {
throw new IllegalStateException("Logging config file is invalid", ex);
}
engine.setLoggingConfigFile(PathUtils.fileToPath(loggingConfigFilePath));
}

if (x509Certificates != null && !x509Certificates.isEmpty()) {
Expand All @@ -1053,11 +1045,7 @@ private Engine createEngine() {

// Working directory settings
if (workDir != null) {
try {
engine.setWorkDir(PathUtils.fileToPath(workDir));
} catch (IOException ex) {
throw new IllegalStateException("Work directory path is invalid", ex);
}
engine.setWorkDir(PathUtils.fileToPath(workDir));
}
engine.setInternalDir(internalDir);
engine.setFailIfWorkDirIsMissing(failIfWorkDirIsMissing);
Expand Down

0 comments on commit 713e3b0

Please sign in to comment.