-
-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Create ClassLoaders inside doPrivileged() + Auto-close the WAR file after exploding it #411
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,9 @@ | |
import java.net.URLClassLoader; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.security.AccessController; | ||
import java.security.PrivilegedActionException; | ||
import java.security.PrivilegedExceptionAction; | ||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
@@ -41,7 +44,7 @@ public class Bootstrap { | |
|
||
@Option(name = "-jv", aliases = { "--jenkins-version"}, usage = "jenkins version to use (only in case 'warDir' is not specified). Defaults to latest LTS.") | ||
public String version; | ||
|
||
/** | ||
* Where to load plugins from? | ||
*/ | ||
|
@@ -108,7 +111,7 @@ public class Bootstrap { | |
|
||
@Option(name = "-v", aliases = { "--version" }, usage = "Prints the current Jenkinsfile Runner version") | ||
public boolean showVersion; | ||
|
||
@Option(name = "-h", aliases = { "--help"}, usage = "Prints help information.", help = true, forbids = { "-v", "-w", "-p", "-f", "--runWorkspace" }) | ||
public boolean help; | ||
|
||
|
@@ -237,7 +240,7 @@ public void postConstruct(CmdLineParser parser) throws IOException { | |
} | ||
} | ||
|
||
private String getVersion() throws IOException { | ||
private String getVersion() { | ||
return getClass().getPackage().getImplementationVersion(); | ||
} | ||
|
||
|
@@ -338,12 +341,12 @@ public int run() throws Throwable { | |
} | ||
} | ||
|
||
public ClassLoader createJenkinsWarClassLoader() throws IOException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { | ||
return new ClassLoaderBuilder(new SideClassLoader(getPlatformClassloader())) | ||
.collectJars(new File(warDir,"WEB-INF/lib")) | ||
public ClassLoader createJenkinsWarClassLoader() throws PrivilegedActionException { | ||
return AccessController.doPrivileged((PrivilegedExceptionAction<ClassLoader>) () -> new ClassLoaderBuilder(new SideClassLoader(getPlatformClassloader())) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Jenkins is unlikely to work on advanced security policies . Should be fine though I will need to add Autotests for the resource loading There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is pointless. See spotbugs/spotbugs#1515 |
||
.collectJars(new File(warDir, "WEB-INF/lib")) | ||
// servlet API needs to be visible to jenkins.war | ||
.collectJars(new File(getAppRepo(),"javax/servlet")) | ||
.make(); | ||
.collectJars(new File(getAppRepo(), "javax/servlet")) | ||
.make()); | ||
} | ||
|
||
public ClassLoader createSetupClassLoader(ClassLoader jenkins) throws IOException { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not recall what led to this exception list