Skip to content

Commit

Permalink
Merge pull request jenkinsci#193 from witokondoria/fix/DifferentError…
Browse files Browse the repository at this point in the history
…CodesHandling

[JENKINS-46515] exit the Launcher process on 4XX errors
  • Loading branch information
jeffret-b authored Apr 30, 2019
2 parents ab254bb + c5a0883 commit 21e59c5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/hudson/remoting/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.io.Console;
import java.io.FileInputStream;
import java.io.UnsupportedEncodingException;
import java.io.FileNotFoundException;
import java.nio.file.Path;
import java.security.KeyStore;
import java.security.KeyStoreException;
Expand Down Expand Up @@ -491,9 +492,12 @@ public List<String> parseJnlpArguments() throws ParserConfigurationException, SA

if (con instanceof HttpURLConnection) {
HttpURLConnection http = (HttpURLConnection) con;
if(http.getResponseCode()>=400)
if(http.getResponseCode()>=500)
// got the error code. report that (such as 401)
throw new IOException("Failed to load "+slaveJnlpURL+": "+http.getResponseCode()+" "+http.getResponseMessage());
if(http.getResponseCode()>=400)
// got the error code. report that (such as 401)
throw new FileNotFoundException("Failed to load "+slaveJnlpURL+": "+http.getResponseCode()+" "+http.getResponseMessage());
}

Document dom;
Expand Down Expand Up @@ -550,6 +554,11 @@ public List<String> parseJnlpArguments() throws ParserConfigurationException, SA
throw x;
} else
throw e;
} catch (FileNotFoundException e) {
System.err.println("Failing to obtain "+slaveJnlpURL);
e.printStackTrace(System.err);
System.err.println("Will silently exit without errors");
System.exit(0);
} catch (IOException e) {
if (this.noReconnect)
throw (IOException)new IOException("Failing to obtain "+slaveJnlpURL).initCause(e);
Expand Down

0 comments on commit 21e59c5

Please sign in to comment.