Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FIXED JENKINS-25348]
Added necessary additions. Now the clients of this plugin needs to be modified to use this newly added method.
- Loading branch information
Showing
4 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...java/org/jenkinsci/plugins/scriptsecurity/sandbox/groovy/SandboxResolvingClassLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.jenkinsci.plugins.scriptsecurity.sandbox.groovy; | ||
|
||
import groovy.lang.GroovyShell; | ||
|
||
/** | ||
* Makes sure that the class references to groovy-sandbox resolves to our own copy of | ||
* <tt>groovy-sandbox.jar</tt> instead of the random one picked up by the classloader | ||
* given to {@link GroovyShell} via the constructor. | ||
* | ||
* @see <a href="https://issues.jenkins-ci.org/browse/JENKINS-25348">JENKINS-25438</a> | ||
* @author Kohsuke Kawaguchi | ||
*/ | ||
class SandboxResolvingClassLoader extends ClassLoader { | ||
public SandboxResolvingClassLoader(ClassLoader parent) { | ||
super(parent); | ||
} | ||
|
||
@Override | ||
protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { | ||
if (name.startsWith("org.kohsuke.groovy.sandbox.")) { | ||
return this.getClass().getClassLoader().loadClass(name); | ||
} else { | ||
return super.loadClass(name, resolve); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters