SAP-archive / cloud-s4-sdk-pipeline-lib

The SAP Cloud SDK pipeline library defines essential functions for building cloud extension applications. The SAP Cloud SDK pipeline uses this library.
Apache License 2.0
27 stars 22 forks source link

CPS issue in setupMtaProject #16

Closed CCFenner closed 5 years ago

CCFenner commented 5 years ago

The following code seems to lead to a CPS warning.

https://github.com/SAP/cloud-s4-sdk-pipeline-lib/blob/10c02a32389bdc31dabe496f93ab13c9ebc3d350/vars/setupMtaProject.groovy#L23-L25

Log:

5783[Pipeline] End of Pipeline
5784java.lang.IllegalStateException: expected to call java.util.stream.ReferencePipeline$Head.forEach but wound up catching org.jenkinsci.plugins.workflow.cps.CpsClosure2.call; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/
5785    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService.handleMismatch(CpsVmExecutorService.java:117)
5786    at com.cloudbees.groovy.cps.impl.CpsCallableInvocation.checkMismatch(CpsCallableInvocation.java:63)
5787    at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:94)
5788    at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
5789    at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83)
5790    at sun.reflect.GeneratedMethodAccessor84.invoke(Unknown Source)
5791    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
5792    at java.lang.reflect.Method.invoke(Method.java:498)
5793    at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
5794    at setupMtaProject.call(setupMtaProject.groovy:23)
5795    at initS4sdkPipeline.call(initS4sdkPipeline.groovy:46)
5796    at stageInitS4sdkPipeline.call(stageInitS4sdkPipeline.groovy:14)
5797    at runAsStage.executeStage(runAsStage.groovy:96)
5798    at runAsStage.call(runAsStage.groovy:51)
5799    at ___cps.transform___(Native Method)
5800    at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46)
5801    at com.cloudbees.groovy.cps.Next.step(Next.java:83)
5802    at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
5803    at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
5804    at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
5805    at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
5806    at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
5807    at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:186)
5808    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:370)
5809    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:93)
5810    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:282)
5811    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:270)
5812    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:66)
5813    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
5814    at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
5815    at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
5816    at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
5817    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
5818    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
5819    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
5820    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
5821    at java.lang.Thread.run(Thread.java:748)
5822Finished: FAILURE

Any idea how to fix this? Maybe extracting this to a @NonCPS method helps.

fwilhe commented 5 years ago

Thanks for reporting, was not aware of this instance before. I think we need to get rid of the stream and do it the old java 6 way..

fwilhe commented 5 years ago

Resolved by replacing with a for loop, waiting for our internal ci to push the change.

fwilhe commented 5 years ago

Fixed in https://github.com/SAP/cloud-s4-sdk-pipeline-lib/commit/ed2d26be4864ddd1cece658843bc35f53b0dabaf