Skip to content
Permalink
Browse files
JENKINS-31690 fix for getGroovyBinding NPE
  • Loading branch information
vimil committed Dec 28, 2015
1 parent d24321d commit 719e73494132baf272abe4a461da6ee0eeb344e1
@@ -47,7 +47,6 @@
import org.apache.commons.lang.StringUtils;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Property;
import org.boon.Boon;
import org.codehaus.groovy.control.CompilerConfiguration;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.Stapler;
@@ -686,11 +685,18 @@ private String computeMD5Hash(String str) {
}

private Binding getGroovyBinding() {
Binding groovyBinding = null;

StaplerRequest currentRequest = Stapler.getCurrentRequest();
Binding groovyBinding = (Binding)currentRequest.getAttribute(ATTR_REQUEST_GROOVY_BINDING);
if(groovyBinding == null) {
if(currentRequest != null) {
groovyBinding = (Binding)currentRequest.getAttribute(ATTR_REQUEST_GROOVY_BINDING);
if(groovyBinding == null) {
groovyBinding = new Binding();
currentRequest.setAttribute(ATTR_REQUEST_GROOVY_BINDING, groovyBinding);
}
}
else {
groovyBinding = new Binding();
currentRequest.setAttribute(ATTR_REQUEST_GROOVY_BINDING, groovyBinding);
}
return groovyBinding;
}

0 comments on commit 719e734

Please sign in to comment.