Skip to content

Commit

Permalink
[JENKINS-49237] - Improve diagnosability of JEP-200 exceptions in Bui…
Browse files Browse the repository at this point in the history
…ldProxy
  • Loading branch information
oleg-nenashev committed Jan 30, 2018
1 parent a4f7dd6 commit 0d7a4a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/main/java/hudson/plugins/helpers/BuildProxy.java
Expand Up @@ -56,6 +56,7 @@ public static boolean doPerform(Ghostwriter ghostwriter,
// construct the BuildProxy instance that we will use

BuildProxy buildProxy = new BuildProxy(
//TODO: It is not compatible with custom artifact managers
new FilePath(build.getArtifactsDir()),
new FilePath(build.getProject().getRootDir()),
new FilePath(build.getRootDir()),
Expand Down Expand Up @@ -86,6 +87,7 @@ public static boolean doPerform(Ghostwriter ghostwriter,
|| masterGhostwriter.performFromMaster(build, build.getModuleRoot(), listener);
}

//TODO: this logic undermines error propagation in the code
/**
* Takes a remote exception that has been wrapped up in the remoting layer, and rethrows it as IOException,
* InterruptedException or if all else fails, a RuntimeException.
Expand All @@ -100,15 +102,19 @@ public static boolean doPerform(Ghostwriter ghostwriter,
private static RuntimeException unwrapException(Exception e,
BuildListener listener)
throws IOException, InterruptedException {

if (e.getCause() instanceof IOException) {
throw new IOException2(e.getCause().getMessage(), e);
throw new IOException(e.getCause().getMessage(), e);
}
if (e.getCause() instanceof InterruptedException) {
e.getCause().printStackTrace(listener.getLogger());
throw new InterruptedException(e.getCause().getMessage());
}
if (e.getCause() instanceof RuntimeException) {
throw new RuntimeException(e.getCause());
RuntimeException ex = new RuntimeException(e.getCause());
// It is required to triage JEP-200 security exceptions
ex.addSuppressed(e);
throw ex;
}
// How on earth do we get this far down the branch
e.printStackTrace(listener.getLogger());
Expand Down
@@ -1,7 +1,6 @@
package hudson.plugins.helpers;

import hudson.model.BuildListener;
import hudson.remoting.Callable;
import jenkins.security.MasterToSlaveCallable;

import java.io.IOException;
Expand Down

0 comments on commit 0d7a4a9

Please sign in to comment.