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

CPS-transformed field initialization including operations causes NPE in transformation

      So now code like this:

      class C {
        String f = "banana"
        String g = "other " + f
      }
      

      ...will cause a NullPointerException in compilation/transformation - see below for the stacktrace.

      The root cause is that groovy-cps:1.17 started calling SandboxTransfromer.VisitorImpl.visitField to sandbox class fields, but there's no varScope set when those fields are visited, so ScopeTrackingClassCodeExpressionTransformer.isLocalVariable blows up.
       

      [Bitbucket] Notifying commit build result
      [Bitbucket] Build result notified
      java.lang.NullPointerException: Cannot invoke method has() on null object
      at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:91)
      at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:48)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:35)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:58)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
      at org.kohsuke.groovy.sandbox.ScopeTrackingClassCodeExpressionTransformer.isLocalVariable(ScopeTrackingClassCodeExpressionTransformer.groovy:35)
      at org.kohsuke.groovy.sandbox.ScopeTrackingClassCodeExpressionTransformer$isLocalVariable$0.callCurrent(Unknown Source)
      at org.kohsuke.groovy.sandbox.SandboxTransformer$VisitorImpl.innerTransform(SandboxTransformer.groovy:288)
      at org.kohsuke.groovy.sandbox.SandboxTransformer$VisitorImpl.this$6$innerTransform(SandboxTransformer.groovy)
      at sun.reflect.GeneratedMethodAccessor811.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
      at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
      at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:64)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
      at org.kohsuke.groovy.sandbox.SandboxTransformer$VisitorImpl.transform(SandboxTransformer.groovy:188)
      at org.codehaus.groovy.ast.expr.ExpressionTransformer$transform.callCurrent(Unknown Source)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
      at org.codehaus.groovy.ast.expr.ExpressionTransformer$transform.callCurrent(Unknown Source)
      at org.kohsuke.groovy.sandbox.SandboxTransformer$VisitorImpl.innerTransform(SandboxTransformer.groovy:418)
      at org.kohsuke.groovy.sandbox.SandboxTransformer$VisitorImpl.this$6$innerTransform(SandboxTransformer.groovy)
      at sun.reflect.GeneratedMethodAccessor811.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
      at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
      at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:64)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
      at org.kohsuke.groovy.sandbox.SandboxTransformer$VisitorImpl.transform(SandboxTransformer.groovy:188)
      at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitField(ClassCodeExpressionTransformer.java:68)
      at com.cloudbees.groovy.cps.SandboxCpsTransformer.visitNontransformedField(SandboxCpsTransformer.java:46)
      at com.cloudbees.groovy.cps.CpsTransformer.call(CpsTransformer.java:132)
      at com.cloudbees.groovy.cps.SandboxCpsTransformer.call(SandboxCpsTransformer.java:26)
      at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1065)
      Caused: BUG! exception in phase 'canonicalization' in source unit 'file:.../src/C.groovy' unexpected NullpointerException
      at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1070)
      at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
      at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
      at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
      at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
      at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
      at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
      at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
      at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:129)
      at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:123)
      at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:516)
      at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:479)
      at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:268)
      at hudson.model.ResourceController.execute(ResourceController.java:97)
      at hudson.model.Executor.run(Executor.java:405)
      Finished: FAILURE
      

       

       

          [JENKINS-45629] CPS-transformed field initialization including operations causes NPE in transformation

          Andrew Bayer added a comment -

          jglick - I think that we can just always return false from isLocalVariable if there's no varScope - that should only be happening for cases like the above, I think, and in those cases, well, it's not a local variable. Tests pass with that changed but I just want to make sure there's nothing glaringly wrong with that idea.

          Andrew Bayer added a comment - jglick - I think that we can just always return false from isLocalVariable if there's no varScope - that should only be happening for cases like the above, I think, and in those cases, well, it's not a local variable. Tests pass with that changed but I just want to make sure there's nothing glaringly wrong with that idea.

          Jesse Glick added a comment -

          https://github.com/kohsuke/groovy-sandbox/pull/33/commits/e6447ef32d554d1de7734bc76aa752ad0bc9fd4c already fixes it I think, unless you are seeing something else.

          Jesse Glick added a comment - https://github.com/kohsuke/groovy-sandbox/pull/33/commits/e6447ef32d554d1de7734bc76aa752ad0bc9fd4c  already fixes it I think, unless you are seeing something else.

          Andrew Bayer added a comment -

          Yup, that should do the trick nicely.

          Andrew Bayer added a comment - Yup, that should do the trick nicely.

          Veaceslav Gaidarji added a comment - - edited

          It fixed the issue for me as well (Jenkins 2.60.1).
          I've used mentioned commit from groovy-sandbox (1.12-SNAPSHOT) repository and prepared script-secutiry-plugin hpi (1.30-SNAPSHOT).
          Would be nice to have an official release of the fix in the near future.

          Veaceslav Gaidarji added a comment - - edited It fixed the issue for me as well (Jenkins 2.60.1). I've used mentioned commit from groovy-sandbox (1.12-SNAPSHOT) repository and prepared script-secutiry-plugin hpi (1.30-SNAPSHOT). Would be nice to have an official release of the fix in the near future.

          Is there a workaround for this?

          We've hit this on our systems with Jenkins 2.60.2, workflow-cps-plugin 2.36.1, and script-security-plugin 1.29.1.

          java.lang.NullPointerException: Cannot invoke method has() on null object
          	at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:91)
          	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:48)
          	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
          	at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:35)
          	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
          	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:57)
          	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
          	at org.kohsuke.groovy.sandbox.ScopeTrackingClassCodeExpressionTransformer.isLocalVariable(ScopeTrackingClassCodeExpressionTransformer.groovy:35)
          	at sun.reflect.GeneratedMethodAccessor2569.invoke(Unknown Source)
          	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          	at java.lang.reflect.Method.invoke(Method.java:498)
          	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
          	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
          	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1218)
          	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1027)
          	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
          	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
          	at org.kohsuke.groovy.sandbox.SandboxTransformer$VisitorImpl.innerTransform(SandboxTransformer.groovy:288)
          	at org.kohsuke.groovy.sandbox.SandboxTransformer$VisitorImpl.this$6$innerTransform(SandboxTransformer.groovy)
          	at sun.reflect.GeneratedMethodAccessor138.invoke(Unknown Source)
          	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          	at java.lang.reflect.Method.invoke(Method.java:498)
          	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
          	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
          	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1218)
          	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1027)
          	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
          	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
          	at org.kohsuke.groovy.sandbox.SandboxTransformer$VisitorImpl.transform(SandboxTransformer.groovy:188)
          	at sun.reflect.GeneratedMethodAccessor2068.invoke(Unknown Source)
          	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          	at java.lang.reflect.Method.invoke(Method.java:498)
          	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
          	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
          	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1218)
          	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1027)
          	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
          	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
          	at org.kohsuke.groovy.sandbox.SandboxTransformer$VisitorImpl.transformObjectExpression(SandboxTransformer.groovy:510)
          	at org.kohsuke.groovy.sandbox.SandboxTransformer$VisitorImpl.this$6$transformObjectExpression(SandboxTransformer.groovy)
          	at sun.reflect.GeneratedMethodAccessor1546.invoke(Unknown Source)
          	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          	at java.lang.reflect.Method.invoke(Method.java:498)
          	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
          	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
          	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1218)
          	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1027)
          	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
          	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
          	at org.kohsuke.groovy.sandbox.SandboxTransformer$VisitorImpl.innerTransform(SandboxTransformer.groovy:279)
          	at org.kohsuke.groovy.sandbox.SandboxTransformer$VisitorImpl.this$6$innerTransform(SandboxTransformer.groovy)
          	at sun.reflect.GeneratedMethodAccessor138.invoke(Unknown Source)
          	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          	at java.lang.reflect.Method.invoke(Method.java:498)
          	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
          	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
          	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1218)
          	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1027)
          	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
          	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
          	at org.kohsuke.groovy.sandbox.SandboxTransformer$VisitorImpl.transform(SandboxTransformer.groovy:188)
          	at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitField(ClassCodeExpressionTransformer.java:68)
          	at com.cloudbees.groovy.cps.SandboxCpsTransformer.visitNontransformedField(SandboxCpsTransformer.java:46)
          	at com.cloudbees.groovy.cps.CpsTransformer.call(CpsTransformer.java:132)
          	at com.cloudbees.groovy.cps.SandboxCpsTransformer.call(SandboxCpsTransformer.java:26)
          	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1065)
          	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
          	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
          	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
          	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
          	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
          	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:254)
          	at groovy.lang.GroovyClassLoader.recompile(GroovyClassLoader.java:761)
          	at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:718)
          	at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:787)
          	at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:775)
          	at org.jenkinsci.plugins.workflow.cps.global.UserDefinedGlobalVariable.getValue(UserDefinedGlobalVariable.java:54)
          	at org.jenkinsci.plugins.workflow.cps.CpsScript.getProperty(CpsScript.java:121)
          	at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:174)
          	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:456)
          	at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:243)
          	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onGetProperty(GroovyInterceptor.java:52)
          	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:308)
          	at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:241)
          	at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:238)
          	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:28)
          	at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
          Caused: BUG! exception in phase 'canonicalization' in source unit '/var/lib/jenkins/jobs/deep-learning-platform/jobs/dlaas-trainer-service/branches/PR-24/builds/2/libs/dlaas-library/vars/devwat_cruiser4_test_dlaas.groovy' unexpected NullpointerException
          	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1070)
          	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
          	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
          	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
          	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
          	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
          	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:254)
          	at groovy.lang.GroovyClassLoader.recompile(GroovyClassLoader.java:761)
          	at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:718)
          	at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:787)
          	at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:775)
          	at org.jenkinsci.plugins.workflow.cps.global.UserDefinedGlobalVariable.getValue(UserDefinedGlobalVariable.java:54)
          	at org.jenkinsci.plugins.workflow.cps.CpsScript.getProperty(CpsScript.java:121)
          	at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:174)
          	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:456)
          	at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:243)
          	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onGetProperty(GroovyInterceptor.java:52)
          	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:308)
          	at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:241)
          	at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:238)
          	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:28)
          	at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
          	at WorkflowScript.run(WorkflowScript:43)
          	at ___cps.transform___(Native Method)
          	at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:74)
          	at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
          	at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:66)
          	at sun.reflect.GeneratedMethodAccessor432.invoke(Unknown Source)
          	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          	at java.lang.reflect.Method.invoke(Method.java:498)
          	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
          	at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
          	at com.cloudbees.groovy.cps.Next.step(Next.java:83)
          	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:173)
          	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:162)
          	at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:122)
          	at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:261)
          	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:162)
          	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:19)
          	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:35)
          	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:32)
          	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
          	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:32)
          	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174)
          	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:330)
          	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:82)
          	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:242)
          	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:230)
          	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
          	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:748)
          

          Christian Höltje added a comment - Is there a workaround for this? We've hit this on our systems with Jenkins 2.60.2, workflow-cps-plugin 2.36.1, and script-security-plugin 1.29.1. java.lang.NullPointerException: Cannot invoke method has() on null object at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:91) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:48) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:35) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:57) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) at org.kohsuke.groovy.sandbox.ScopeTrackingClassCodeExpressionTransformer.isLocalVariable(ScopeTrackingClassCodeExpressionTransformer.groovy:35) at sun.reflect.GeneratedMethodAccessor2569.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1218) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1027) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166) at org.kohsuke.groovy.sandbox.SandboxTransformer$VisitorImpl.innerTransform(SandboxTransformer.groovy:288) at org.kohsuke.groovy.sandbox.SandboxTransformer$VisitorImpl.this$6$innerTransform(SandboxTransformer.groovy) at sun.reflect.GeneratedMethodAccessor138.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1218) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1027) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166) at org.kohsuke.groovy.sandbox.SandboxTransformer$VisitorImpl.transform(SandboxTransformer.groovy:188) at sun.reflect.GeneratedMethodAccessor2068.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1218) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1027) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166) at org.kohsuke.groovy.sandbox.SandboxTransformer$VisitorImpl.transformObjectExpression(SandboxTransformer.groovy:510) at org.kohsuke.groovy.sandbox.SandboxTransformer$VisitorImpl.this$6$transformObjectExpression(SandboxTransformer.groovy) at sun.reflect.GeneratedMethodAccessor1546.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1218) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1027) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166) at org.kohsuke.groovy.sandbox.SandboxTransformer$VisitorImpl.innerTransform(SandboxTransformer.groovy:279) at org.kohsuke.groovy.sandbox.SandboxTransformer$VisitorImpl.this$6$innerTransform(SandboxTransformer.groovy) at sun.reflect.GeneratedMethodAccessor138.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1218) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1027) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166) at org.kohsuke.groovy.sandbox.SandboxTransformer$VisitorImpl.transform(SandboxTransformer.groovy:188) at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitField(ClassCodeExpressionTransformer.java:68) at com.cloudbees.groovy.cps.SandboxCpsTransformer.visitNontransformedField(SandboxCpsTransformer.java:46) at com.cloudbees.groovy.cps.CpsTransformer.call(CpsTransformer.java:132) at com.cloudbees.groovy.cps.SandboxCpsTransformer.call(SandboxCpsTransformer.java:26) at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1065) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:254) at groovy.lang.GroovyClassLoader.recompile(GroovyClassLoader.java:761) at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:718) at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:787) at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:775) at org.jenkinsci.plugins.workflow.cps.global.UserDefinedGlobalVariable.getValue(UserDefinedGlobalVariable.java:54) at org.jenkinsci.plugins.workflow.cps.CpsScript.getProperty(CpsScript.java:121) at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:174) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:456) at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:243) at org.kohsuke.groovy.sandbox.GroovyInterceptor.onGetProperty(GroovyInterceptor.java:52) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:308) at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:241) at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:238) at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:28) at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20) Caused: BUG! exception in phase 'canonicalization' in source unit '/var/lib/jenkins/jobs/deep-learning-platform/jobs/dlaas-trainer-service/branches/PR-24/builds/2/libs/dlaas-library/vars/devwat_cruiser4_test_dlaas.groovy' unexpected NullpointerException at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1070) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:254) at groovy.lang.GroovyClassLoader.recompile(GroovyClassLoader.java:761) at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:718) at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:787) at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:775) at org.jenkinsci.plugins.workflow.cps.global.UserDefinedGlobalVariable.getValue(UserDefinedGlobalVariable.java:54) at org.jenkinsci.plugins.workflow.cps.CpsScript.getProperty(CpsScript.java:121) at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:174) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:456) at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:243) at org.kohsuke.groovy.sandbox.GroovyInterceptor.onGetProperty(GroovyInterceptor.java:52) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:308) at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:241) at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:238) at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:28) at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20) at WorkflowScript.run(WorkflowScript:43) at ___cps.transform___(Native Method) at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:74) at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30) at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:66) at sun.reflect.GeneratedMethodAccessor432.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72) at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21) at com.cloudbees.groovy.cps.Next.step(Next.java:83) at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:173) at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:162) at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:122) at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:261) at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:162) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:19) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:35) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:32) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:32) at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:330) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:82) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:242) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:230) at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64) 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:748)

          Yes, this is a workaround. I can send you an hpi which can be used temporary until the fix is shipped.

          Veaceslav Gaidarji added a comment - Yes, this is a workaround. I can send you an hpi which can be used temporary until the fix is shipped.

          Jesse Glick added a comment -

          Should be fixed in master branch, pending release. Workaround should be trivial: move initializers to a constructor.

          Jesse Glick added a comment - Should be fixed in master branch, pending release. Workaround should be trivial: move initializers to a constructor.

          Jesse Glick added a comment -

          Fix is actually in script-security 1.30.

          Jesse Glick added a comment - Fix is actually in script-security 1.30.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          pom.xml
          src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition2Test.java
          http://jenkins-ci.org/commit/workflow-cps-plugin/9751df6154df9e10aeb965efb218cbb31c1f2ee7
          Log:
          Picking up script-security 1.30 release, and demonstrating fix of JENKINS-45629.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: pom.xml src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition2Test.java http://jenkins-ci.org/commit/workflow-cps-plugin/9751df6154df9e10aeb965efb218cbb31c1f2ee7 Log: Picking up script-security 1.30 release, and demonstrating fix of JENKINS-45629 .

          Code changed in jenkins
          User: Jesse Glick
          Path:
          src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition2Test.java
          http://jenkins-ci.org/commit/workflow-cps-plugin/ebd87bb3e42318e3f0d8a68d00529999fd2fa248
          Log:
          Merge pull request #157 from jglick/final-fields-JENKINS-34599

          JENKINS-34599 JENKINS-45629 Demonstrating fixes

          Compare: https://github.com/jenkinsci/workflow-cps-plugin/compare/bcca2269e873...ebd87bb3e423

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition2Test.java http://jenkins-ci.org/commit/workflow-cps-plugin/ebd87bb3e42318e3f0d8a68d00529999fd2fa248 Log: Merge pull request #157 from jglick/final-fields- JENKINS-34599 JENKINS-34599 JENKINS-45629 Demonstrating fixes Compare: https://github.com/jenkinsci/workflow-cps-plugin/compare/bcca2269e873...ebd87bb3e423

            jglick Jesse Glick
            thawkins83 T.J. Hawkins
            Votes:
            5 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: