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

Indirect NotSerializableException: java.util.regex.Matcher

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • pipeline
    • None
    • Jenkins 2.235.3
      Pipeline: API 2.40
      Pipeline: Basic Steps 2.20
      Pipeline: Stage Step 2.5

      The following sample will intermittently throw NotSerializableException: java.util.regex.Matcher.  However, this code does not directly use a Matcher.  Seems like this problem could exist anywhere when calling any function that internally uses a non-serializable field that is not annotated as NonCPS.

       

      pipeline {
          agent {
              label 'master'
          }
          stages {
              stage('stage') {
                  steps {
                      script {
                          parallel ((1..20).collect{it}.collectEntries {
                              ["$it": {
                                  node('master') {
                                      stage("$it") {
                                          sh('')
                                          '.'.replaceAll('.', {})
                                      }
                                  }
                              }]
                          })
                      }
                  }
              }
          }
      }
      

      Notes:

      • The sh step must be done.
      • The replaceAll must pass a closure.
      • The empty sh and replaceAll closure are not empty in my production pipeline, but are minimized here for a concise example.  (That is, the solution is not "remove code that does not have any effects").
      • Seems that the upper end of the range needs to be larger than the number of executors.
      • The range must be collected to an Array or it will throw "NotSerializableException: groovy.lang.IntRange", which seems like its own bug as the range is never saved as a field.

            Unassigned Unassigned
            jamessassano James Sassano
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: