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

Cannot call closure element of map as method in sandbox

XMLWordPrintable

      Normal Groovy allows Closure elements of Map instances to be called using method call syntax. That is, the following is valid Groovy:

      def m = [ f: { return 'hello' } ]
      println m.f()

      However, this is rejected by the sandbox:

      groovy.lang.MissingMethodException: No signature of method: java.util.LinkedHashMap.f() is applicable for argument types: () values: []
      Possible solutions: is(java.lang.Object), find(), any(), get(java.lang.Object), get(java.lang.Object), get(java.lang.Object)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:131)
      	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:155)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:159)
      	at org.kohsuke.groovy.sandbox.impl.Checker$checkedCall.callStatic(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
      	at Script1.run(Script1.groovy:4)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.run(GroovySandbox.java:141)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:333)
      	at hudson.plugins.groovy.SystemGroovy.run(SystemGroovy.java:95)
      	at hudson.plugins.groovy.SystemGroovy.perform(SystemGroovy.java:59)
      	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
      	at hudson.model.Build$BuildExecution.build(Build.java:205)
      	at hudson.model.Build$BuildExecution.doRun(Build.java:162)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
      	at hudson.model.Run.execute(Run.java:1741)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      	at hudson.model.ResourceController.execute(ResourceController.java:98)
      	at hudson.model.Executor.run(Executor.java:410)

      Note that the more explicit (m.f)() and m['f']() work just fine.

            rudolfwg Rudolf-Walter Kiss-Szakacs
            rudolfwg Rudolf-Walter Kiss-Szakacs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: