-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
pipeline-aggregator-view 1.8
pipeline-build-step 2.7
pipeline-github-lib 1.0
pipeline-graph-analysis 1.9
pipeline-input-step 2.9
pipeline-milestone-step 1.3.1
pipeline-model-api 1.3.4.1
pipeline-model-declarative-agent 1.1.1
pipeline-model-definition 1.3.4.1
pipeline-model-extensions 1.3.4.1
pipeline-rest-api 2.10
pipeline-stage-step 2.3
pipeline-stage-tags-metadata 1.3.4.1
pipeline-stage-view 2.10
windows-slaves 1.4
workflow-aggregator 2.6
workflow-api 2.33
workflow-basic-steps 2.14
workflow-cps 2.63
workflow-cps-global-lib 2.13
workflow-durable-task-step 2.29
workflow-job 2.31
workflow-multibranch 2.20
workflow-scm-step 2.7
workflow-step-api 2.19
workflow-support 3.2pipeline-aggregator-view 1.8 pipeline-build-step 2.7 pipeline-github-lib 1.0 pipeline-graph-analysis 1.9 pipeline-input-step 2.9 pipeline-milestone-step 1.3.1 pipeline-model-api 1.3.4.1 pipeline-model-declarative-agent 1.1.1 pipeline-model-definition 1.3.4.1 pipeline-model-extensions 1.3.4.1 pipeline-rest-api 2.10 pipeline-stage-step 2.3 pipeline-stage-tags-metadata 1.3.4.1 pipeline-stage-view 2.10 windows-slaves 1.4 workflow-aggregator 2.6 workflow-api 2.33 workflow-basic-steps 2.14 workflow-cps 2.63 workflow-cps-global-lib 2.13 workflow-durable-task-step 2.29 workflow-job 2.31 workflow-multibranch 2.20 workflow-scm-step 2.7 workflow-step-api 2.19 workflow-support 3.2
I receive an intermittent java.io.NotSerializableException when running a script in parallel
an exception which occurred: in field com.cloudbees.groovy.cps.impl.BlockScopeEnv.locals in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@53ce7f91 ... Caused: java.io.NotSerializableException: java.util.regex.Matcher at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:926) ...
The stack trace completely masks the location of the offending code. The offending code is when I'm storing the result of a matcher in a local variable, the main issue is that it was very difficult to locate and that it occurs inconsistently.
I've reduced the steps required to reproduce to the following script:
import com.cloudbees.groovy.cps.NonCPS //Fails when it enters this method, only if method is annotated NonCPS @NonCPS def getMessage(def auth) { return '[abc][def]asdasd' } def getTags() { //Below line is the offending code, it seems to break CPS rules, but it only fails intermittently def tagMatches = getMessage(credentials) =~ /\[(.*?)\]/ def tagsList = [] for (def tagMatch in tagMatches) { tagsList << (tagMatch[1])?.toLowerCase() } tagsList } //This doesn't seem as though it would be relevant, but if I remove it when reproducing the failure doesn't seem to appear, perhaps it causes some necessary delay that causes serialisation in the parallel run? def getCredentials() { withCredentials([ [$class: 'StringBinding', credentialsId: 'SOME_CREDENTIALS', variable: 'TOKEN'] ]) { "any" } } def script = { stage(it) { println tags } } def scripts = [:] for (int i = 0; i < 5; i++) { def runName = "run ${i}" scripts."run ${i}" = { script(runName) } } //Running the scripts sequentially does not cause issue for ( def _script:scripts.values()){ _script() } //Running the scripts in parallel causes the issue parallel scripts