From 713e3b039fbedcb0ea8ee45822c94351bb60902f Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Thu, 26 Oct 2023 18:02:37 -0700 Subject: [PATCH] Directly throw `IOException` (#700) --- src/main/java/hudson/remoting/Launcher.java | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/main/java/hudson/remoting/Launcher.java b/src/main/java/hudson/remoting/Launcher.java index 2214e18e5..c4c699776 100644 --- a/src/main/java/hudson/remoting/Launcher.java +++ b/src/main/java/hudson/remoting/Launcher.java @@ -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(), @@ -1033,18 +1033,10 @@ private Engine createEngine() { // TODO: 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()) { @@ -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);