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

IllegalArgumentException: array element type mismatch from GroovyCallSiteSelector.parametersForVarargs calling String.join with a List

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: script-security-plugin
    • Labels:
      None
    • Environment:
      Script Security 1.21, Jenkins 2.18
    • Sprint:
      Pipeline - December
    • Similar Issues:

      Description

      Pipeline fails if I pass an iterable parameter to String.join, with an error message suggesting it tried to use the vararg overload.

      Jenkinsfile:

      def lst = ['a', 'bc', 'def']
      echo "Lst: $lst"
      
      // Works
      def str = String.join('\n', lst.toArray(new String[lst.size()]))
      echo "Str: $str"
      
      // Doesn't work
      def str2 = String.join('\n', lst)
      echo "Str2: ${str2}"
      

      Console text:

      Started by user dsobral
      DatadogBuildListener.java: Started build!
      DatadogBuildListener.java: Using unix hostname found via `/bin/hostname -f`. Hostname: sfdev-061.richrelevance.com
      DatadogBuildListener.java: Sending event
      DatadogBuildListener.java: API call of type 'v1/events' was sent successfully!
      DatadogBuildListener.java: Payload: {"alert_type":"info","title":"string_join_test build #5 started on sfdev-061.richrelevance.com","text":"%%% \n [Follow build #5 progress](https://jenkins.richrelevance.com/job/string_join_test/5/)  \n %%%","date_happened":1471555196,"event_type":"build start","host":"sfdev-061.richrelevance.com","tags":["job:string_join_test"],"aggregation_key":"string_join_test"}
      [Pipeline] echo
      Lst: [a, bc, def]
      [Pipeline] echo
      Str: a
      bc
      def
      [Pipeline] End of Pipeline
      [BFA] Scanning build for known causes...
      [BFA] No failure causes found
      [BFA] Done. 0s
      DatadogBuildListener.java: Completed build!
      DatadogBuildListener.java: Using unix hostname found via `/bin/hostname -f`. Hostname: sfdev-061.richrelevance.com
      DatadogBuildListener.java: Sending event
      DatadogBuildListener.java: API call of type 'v1/events' was sent successfully!
      DatadogBuildListener.java: Payload: {"source_type_name":"jenkins","alert_type":"failure","title":"string_join_test build #5 failed on sfdev-061.richrelevance.com","text":"%%% \n [See results for build #5](https://jenkins.richrelevance.com/job/string_join_test/5/) (0.0 secs) \n %%%","date_happened":1471555196,"event_type":"build result","host":"sfdev-061.richrelevance.com","result":"FAILURE","tags":["job:string_join_test","result:FAILURE"],"aggregation_key":"string_join_test"}
      DatadogBuildListener.java: Sending metric 'jenkins.job.duration' with value 0.0
      DatadogBuildListener.java: API call of type 'v1/series' was sent successfully!
      DatadogBuildListener.java: Payload: {"series":[{"metric":"jenkins.job.duration","points":[[1471555199,0]],"type":"gauge","host":"sfdev-061.richrelevance.com","tags":["job:string_join_test","result:FAILURE"]}]}
      DatadogBuildListener.java: Sending service check 'jenkins.job.status' with status 2
      DatadogBuildListener.java: API call of type 'v1/check_run' was sent successfully!
      DatadogBuildListener.java: Payload: {"check":"jenkins.job.status","host_name":"sfdev-061.richrelevance.com","timestamp":1471555199,"status":2,"tags":["job:string_join_test","result:FAILURE"]}
      java.lang.IllegalArgumentException: array element type mismatch
      	at java.lang.reflect.Array.set(Native Method)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovyCallSiteSelector.parametersForVarargs(GroovyCallSiteSelector.java:102)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovyCallSiteSelector.matches(GroovyCallSiteSelector.java:49)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovyCallSiteSelector.findMatchingMethod(GroovyCallSiteSelector.java:177)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovyCallSiteSelector.staticMethod(GroovyCallSiteSelector.java:171)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onStaticCall(SandboxInterceptor.java:135)
      	at org.kohsuke.groovy.sandbox.impl.Checker$2.call(Checker.java:180)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedStaticCall(Checker.java:177)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:91)
      	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16)
      	at WorkflowScript.run(WorkflowScript:9)
      	at ___cps.transform___(Native Method)
      	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:48)
      	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
      	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
      	at sun.reflect.GeneratedMethodAccessor852.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
      	at com.cloudbees.groovy.cps.impl.LocalVariableBlock$LocalVariable.get(LocalVariableBlock.java:33)
      	at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
      	at com.cloudbees.groovy.cps.impl.LocalVariableBlock.evalLValue(LocalVariableBlock.java:22)
      	at com.cloudbees.groovy.cps.LValueBlock$BlockImpl.eval(LValueBlock.java:55)
      	at com.cloudbees.groovy.cps.LValueBlock.eval(LValueBlock.java:16)
      	at com.cloudbees.groovy.cps.Next.step(Next.java:58)
      	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:30)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30)
      	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:164)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:360)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:80)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:226)
      	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
      	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      Finished: FAILURE
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                dcsobral Daniel Sobral
              • Votes:
                10 Vote for this issue
                Watchers:
                16 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: