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

Serialization error at end of flow not reported properly in build log, only Jenkins log

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Minor
    • Resolution: Fixed
    • None
    • Jenkins 1.596.1
      Workflow plugin 1.4

      Xubuntu 14.04

      Java(TM) SE Runtime Environment (build 1.7.0_76-b13)

    Description

      We start by creating a class in the groovy script but we've also tried having another groovy script as well as create the class in Java.

      When we then declare create an object with the class "def sc = new SimpleClass("Nisse")" the workflow will exit with an error code.

      The part "echo "this is the end"" will not be executed.

      If I remove the def sc = new ... then the job will exit and all the echo commands will run.

      workflow.groovy
      class SimpleClass{
          
          def name = ""
          
          public SimpleClass(def name){
              this.name = name
          }    
          
          public def greet(){
              return "Hello " + this.name
          }
          
      }
      
      def sc = new SimpleClass("Nisse")
      
      echo sc.greet()
      node("linux || windows") {
          echo "enter node"
          ws("rb-sb-revision") {
              echo "Node + WS 1"
          }
          echo "exit WS"
      }
      echo "this is the end"
      

      Attachments

        Issue Links

          Activity

            If I on the other hand write like this the job will complete and the build will be green

            echo sc.greet()
            node("linux || windows") {
                echo "enter node"
                ws("rb-sb-revision") {
                    def sc = new SimpleClass("Nisse")
                    echo "Node + WS 1"
                }
                echo "exit WS"
            }
            echo "this is the end"
            
            hanabishi Marcus Jacobsson added a comment - If I on the other hand write like this the job will complete and the build will be green echo sc.greet() node( "linux || windows" ) { echo "enter node" ws( "rb-sb-revision" ) { def sc = new SimpleClass( "Nisse" ) echo "Node + WS 1" } echo "exit WS" } echo " this is the end"
            jglick Jesse Glick added a comment -

            Reproduced, after deleting the irrelevant label on node.

            org.jenkinsci.plugins.workflow.cps.CpsThreadGroup propagateErrorToWorkflow
            WARNING: encountered error but could pass it to the flow
            java.io.NotSerializableException: SimpleClass
            	at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
            	at …
            	at org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:111)
            	at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.writeObject(RiverWriter.java:133)
            	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:341)
            	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:325)
            	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:300)
            	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$000(CpsThreadGroup.java:71)
            	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:177)
            	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:175)
            	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47)
            	at …
            Caused by: an exception which occurred:
            	in field locals
            	in field capture
            	in field def
            	in field closures
            	in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@4f9dd39d
            

            Fixed by adding implements Serializable to the class definition.

            jglick Jesse Glick added a comment - Reproduced, after deleting the irrelevant label on node . org.jenkinsci.plugins.workflow.cps.CpsThreadGroup propagateErrorToWorkflow WARNING: encountered error but could pass it to the flow java.io.NotSerializableException: SimpleClass at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860) at … at org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:111) at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.writeObject(RiverWriter.java:133) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:341) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:325) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:300) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$000(CpsThreadGroup.java:71) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:177) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:175) at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47) at … Caused by: an exception which occurred: in field locals in field capture in field def in field closures in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@4f9dd39d Fixed by adding implements Serializable to the class definition.
            jglick Jesse Glick added a comment -

            Note that saveProgram initially catches this error and propagateErrorToWorkflow evidently finds a thread to send it to:

            … org.jenkinsci.plugins.workflow.cps.CpsThread runNextChunk
            FINE: runNextChunk on abnormal[java.io.NotSerializableException: SimpleClass]
            … org.jenkinsci.plugins.workflow.cps.CpsThread runNextChunk
            FINE: ran and produced error
            java.io.NotSerializableException: SimpleClass
            	at …
            

            Yet this does not get put in the log, for whatever reason. It is only after several such occurrences that propagateErrorToWorkflow is run and does not have a thread to send the message to. Later I also see

            … org.jenkinsci.plugins.workflow.cps.CpsStepContext getThread
            FINE: no thread 2 among []
            java.lang.IllegalStateException
            	at org.jenkinsci.plugins.workflow.cps.CpsStepContext.getThread(CpsStepContext.java:219)
            	at org.jenkinsci.plugins.workflow.cps.CpsStepContext$2.onSuccess(CpsStepContext.java:349)
            	at org.jenkinsci.plugins.workflow.cps.CpsStepContext$2.onSuccess(CpsStepContext.java:343)
            	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution$4$1.run(CpsFlowExecution.java:516)
            	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$1.run(CpsVmExecutorService.java:32)
            	at …
            

            The StepEndNode with ID 11 (matching ExecutorStep) does have the correct ErrorAction. Yet the FlowEndNode (12) has result=FAILURE and no ErrorAction, which seems anomalous. WorkflowRun.finish did not print anything because it consults FlowExecution.getCauseOfFailure, which checks only the FlowEndNode for an ErrorAction. Perhaps CpsFlowExecution.onProgramEnd was being called with the wrong Outcome?

            jglick Jesse Glick added a comment - Note that saveProgram initially catches this error and propagateErrorToWorkflow evidently finds a thread to send it to: … org.jenkinsci.plugins.workflow.cps.CpsThread runNextChunk FINE: runNextChunk on abnormal[java.io.NotSerializableException: SimpleClass] … org.jenkinsci.plugins.workflow.cps.CpsThread runNextChunk FINE: ran and produced error java.io.NotSerializableException: SimpleClass at … Yet this does not get put in the log, for whatever reason. It is only after several such occurrences that propagateErrorToWorkflow is run and does not have a thread to send the message to. Later I also see … org.jenkinsci.plugins.workflow.cps.CpsStepContext getThread FINE: no thread 2 among [] java.lang.IllegalStateException at org.jenkinsci.plugins.workflow.cps.CpsStepContext.getThread(CpsStepContext.java:219) at org.jenkinsci.plugins.workflow.cps.CpsStepContext$2.onSuccess(CpsStepContext.java:349) at org.jenkinsci.plugins.workflow.cps.CpsStepContext$2.onSuccess(CpsStepContext.java:343) at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution$4$1.run(CpsFlowExecution.java:516) at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$1.run(CpsVmExecutorService.java:32) at … The StepEndNode with ID 11 (matching ExecutorStep ) does have the correct ErrorAction . Yet the FlowEndNode ( 12 ) has result=FAILURE and no ErrorAction , which seems anomalous. WorkflowRun.finish did not print anything because it consults FlowExecution.getCauseOfFailure , which checks only the FlowEndNode for an ErrorAction . Perhaps CpsFlowExecution.onProgramEnd was being called with the wrong Outcome ?

            So as I understand it from the guide this will never work? Too bad as we kind of need to be able to do this.

            import some.package.SomeClass
            SomeClass a = new SomeClass("World")
            node("A"){
               a.setSomeValue()
               echo a.greet()
            }
            node("B"){
               a.setSomeValue()
               echo a.greet()
            }
            a = null;
            echo "This is the end"
            
            hanabishi Marcus Jacobsson added a comment - So as I understand it from the guide this will never work? Too bad as we kind of need to be able to do this. import some. package .SomeClass SomeClass a = new SomeClass( "World" ) node( "A" ){ a.setSomeValue() echo a.greet() } node( "B" ){ a.setSomeValue() echo a.greet() } a = null ; echo "This is the end"
            jglick Jesse Glick added a comment -

            hanabishi It will work so long as SomeClass implements Serializable. Alternately, you can use an instance of SomeClass locally in a method marked @NonCps (in this case it cannot be used across asynchronous steps like node).

            jglick Jesse Glick added a comment - hanabishi It will work so long as SomeClass implements Serializable . Alternately, you can use an instance of SomeClass locally in a method marked @NonCps (in this case it cannot be used across asynchronous steps like node ).
            abayer Andrew Bayer added a comment -

            Not sure when this was fixed, but it is - the exception shows up in the build logs.

            abayer Andrew Bayer added a comment - Not sure when this was fixed, but it is - the exception shows up in the build logs.
            jglick Jesse Glick added a comment -

            abayer I recommend using Cannot Reproduce for such cases. You do not actually know that something was fixed unless you did reproduce it in an earlier version. And if you did that, then you should at least bisect to find the origin of the fix, and mark as a duplicate. If you have only tried in current versions and did not see the problem, it may just be that you are using a subtly different test case than the reporter.

            jglick Jesse Glick added a comment - abayer I recommend using Cannot Reproduce for such cases. You do not actually know that something was fixed unless you did reproduce it in an earlier version. And if you did that, then you should at least bisect to find the origin of the fix, and mark as a duplicate. If you have only tried in current versions and did not see the problem, it may just be that you are using a subtly different test case than the reporter.

            People

              kohsuke Kohsuke Kawaguchi
              hanabishi Marcus Jacobsson
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: