Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-58611

Implement method comparison for var-args

XMLWordPrintable

      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

       

       

       

       

       

       

            Unassigned Unassigned
            akram Akram Ben Aissi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: