jenkinsci / jenkinsci/script-security-plugin

[JENKINS-58611] Implement method comparison for var-args

Open
#834 2 comments 0 reactions 0 assignees View on GitHub
component:script-security-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
76
Forks
181
Avg merge
14h 55m
Merged PRs (30d)
3

Description

Hi,

our custom DSL for Groovy contains 2 methods named the same way, but with a different number of arguments:

myMethod(boolean watch, String...args)

myMethod(String...args)

 

While trying to call the method from a pipeline, I got the following exception:

 

java.lang.IllegalStateException: cannot compare public com.openshift.jenkins.plugins.OpenShiftDSL$Result com.openshift.jenkins.plugins.OpenShiftDSL.exec(java.lang.Object[]) to public com.openshift.jenkins.plugins.OpenShiftDSL$Result com.openshift.jenkins.plugins.OpenShiftDSL.exec(boolean,java.lang.Object[])

at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovyCallSiteSelector.isMoreSpecific(GroovyCallSiteSelector.java:291)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovyCallSiteSelector.findMatchingMethod(GroovyCallSiteSelector.java:203)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovyCallSiteSelector.method(GroovyCallSiteSelector.java:150)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:90)
at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:156)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:160)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
at WorkflowScript.run(WorkflowScript:13)
at com.openshift.jenkins.plugins.OpenShiftDSL.withProject(jar:file:/var/lib/jenkins/plugins/openshift-client/WEB-INF/lib/openshift-client.jar!/com/openshift/jenkins/plugins/OpenShiftDSL.groovy:395)

 

 

 

It seems that this is due to an incomplete implementation of the method comparison in GroovyCallSiteSelector class. A TODO is still present in the code at the following line:

https://github.com/jenkinsci/script-security-plugin/blob/master/src/main/java/org/jenkinsci/plugins/scriptsecurity/sandbox/groovy/GroovyCallSiteSelector.java#L289

 

 

 

 

 

 

---
Originally reported by akram, imported from: Implement method comparison for var-args


  • status: Open
  • priority: Minor
  • component(s): script-security-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 2
  • imported: 2025-12-09

Raw content of original issue

Hi,

our custom DSL for Groovy contains 2 methods named the same way, but with a different number of arguments:

myMethod(boolean watch, String...args)

myMethod(String...args)

 

While trying to call the method from a pipeline, I got the following exception:

 



java.lang.IllegalStateException: cannot compare public com.openshift.jenkins.plugins.OpenShiftDSL$Result com.openshift.jenkins.plugins.OpenShiftDSL.exec(java.lang.Object[]) to public com.openshift.jenkins.plugins.OpenShiftDSL$Result com.openshift.jenkins.plugins.OpenShiftDSL.exec(boolean,java.lang.Object[])

at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovyCallSiteSelector.isMoreSpecific(GroovyCallSiteSelector.java:291)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovyCallSiteSelector.findMatchingMethod(GroovyCallSiteSelector.java:203)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovyCallSiteSelector.method(GroovyCallSiteSelector.java:150)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:90)
at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:156)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:160)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
at WorkflowScript.run(WorkflowScript:13)
at com.openshift.jenkins.plugins.OpenShiftDSL.withProject(jar:file:/var/lib/jenkins/plugins/openshift-client/WEB-INF/lib/openshift-client.jar!/com/openshift/jenkins/plugins/OpenShiftDSL.groovy:395)


 

 

 

It seems that this is due to an incomplete implementation of the method comparison in GroovyCallSiteSelector class. A TODO is still present in the code at the following line:

https://github.com/jenkinsci/script-security-plugin/blob/master/src/main/java/org/jenkinsci/plugins/scriptsecurity/sandbox/groovy/GroovyCallSiteSelector.java#L289

 

 

 

 

 

 

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.