Skip to content
Permalink
Browse files
[JENKINS-49237] - Improve diagnosability of JEP-200 exceptions in Bui…
…ldProxy
  • Loading branch information
oleg-nenashev committed Jan 30, 2018
1 parent a4f7dd6 commit 0d7a4a928b755d8dedc4c295a252d1242c034fdd
Showing with 8 additions and 3 deletions.
  1. +8 −2 src/main/java/hudson/plugins/helpers/BuildProxy.java
  2. +0 −1 src/main/java/hudson/plugins/helpers/BuildProxyCallableHelper.java
@@ -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()),
@@ -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.
@@ -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());
@@ -1,7 +1,6 @@
package hudson.plugins.helpers;

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

import java.io.IOException;

0 comments on commit 0d7a4a9

Please sign in to comment.