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

Must declare classes to implement Serializable

    XMLWordPrintable

Details

    Description

      A script like

      class C {
        int x
      }
      def c = new C()
      c.x = 5
      sh "echo ${c.x}"
      

      will fail since the local variable c is of a nonserializable type. You need to explicitly say

      class C implements Serializable {
      // ...
      

      Since groovy-cps demands that local variables may be serialized, any locally defined classes must also be serializable (unless they are only ever being passed to binary methods: legal but unlikely).

      Perhaps the transformer could implicitly add implements Serializable to any class declarations it finds. Generally this is harmless: if the class in fact contains some nonserializable fields, trying to serialize an instance will still fail in a predictable way.

      Attachments

        Issue Links

          Activity

            jglick Jesse Glick created issue -
            jglick Jesse Glick made changes -
            Field Original Value New Value
            Epic Link JENKINS-35390 [ 171183 ]
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 167792 ] JNJira + In-Review [ 182845 ]
            abayer Andrew Bayer made changes -
            Component/s pipeline-general [ 21692 ]
            abayer Andrew Bayer made changes -
            Component/s workflow-plugin [ 18820 ]
            jglick Jesse Glick made changes -
            Component/s workflow-cps-plugin [ 21713 ]
            Component/s pipeline [ 21692 ]
            jglick Jesse Glick made changes -
            Link This issue is duplicated by JENKINS-39699 [ JENKINS-39699 ]
            jglick Jesse Glick made changes -
            Issue Type Bug [ 1 ] Improvement [ 4 ]
            jglick Jesse Glick made changes -
            Priority Minor [ 4 ] Major [ 3 ]
            jglick Jesse Glick made changes -
            Link This issue is related to JENKINS-25925 [ JENKINS-25925 ]
            abayer Andrew Bayer made changes -
            Assignee Jesse Glick [ jglick ] Andrew Bayer [ abayer ]
            abayer Andrew Bayer made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            abayer Andrew Bayer made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            abayer Andrew Bayer made changes -
            Remote Link This issue links to "groovy-cps PR #71 (Web Link)" [ 17676 ]
            abayer Andrew Bayer made changes -
            Resolution Fixed [ 1 ]
            Status In Review [ 10005 ] Resolved [ 5 ]
            cloudbees CloudBees Inc. made changes -
            Remote Link This issue links to "CloudBees Internal CD-283 (Web Link)" [ 19071 ]

            People

              abayer Andrew Bayer
              jglick Jesse Glick
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: