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

IssueApi is not serializable

    XMLWordPrintable

Details

    Description

      When After running some tests in parallel in our jenkins pipeline we sometimes get the following error:

      •  java.io.NotSerializableException: io.jenkins.plugins.analysis.core.restapi.IssueApi

       

      Stacktrace:
      15:53:37 Caused: java.io.NotSerializableException: io.jenkins.plugins.analysis.core.restapi.IssueApi*15:53:37* at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:274)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.writeKnownObject(RiverMarshaller.java:696)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:217)15:53:37 at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)15:53:37 at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)15:53:37 at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)15:53:37 at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)15:53:37 at java.base/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:341)15:53:37 at java.base/java.util.HashMap.internalWriteEntries(HashMap.java:1858)15:53:37 at java.base/java.util.HashMap.writeObject(HashMap.java:1412)15:53:37 at org.jboss.marshalling.reflect.JDKSpecific$SerMethods.callWriteObject(JDKSpecific.java:89)15:53:37 at org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:199)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1089)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1080)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1080)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1080)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1080)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1080)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1080)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1080)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1080)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1080)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1080)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1080)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1080)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1080)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)15:53:37 at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)15:53:37 at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)15:53:37 at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)15:53:37 at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)15:53:37 at java.base/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:341)15:53:37 at java.base/java.util.HashMap.internalWriteEntries(HashMap.java:1858)15:53:37 at java.base/java.util.HashMap.writeObject(HashMap.java:1412)15:53:37 at org.jboss.marshalling.reflect.JDKSpecific$SerMethods.callWriteObject(JDKSpecific.java:89)15:53:37 at org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:199)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1089)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)15:53:37 at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)15:53:37 at org.jboss.marshalling.AbstractObjectOutput.writeObject(AbstractObjectOutput.java:58)15:53:37 at org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:116)15:53:37 at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.lambda$writeObject$1(RiverWriter.java:144)15:53:37 at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:331)15:53:37 at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.writeObject(RiverWriter.java:143)15:53:37 at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:578)15:53:37 at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:554)15:53:37 at org.jenkinsci.plugins.workflow.cps.CpsStepContext$3.onSuccess(CpsStepContext.java:553)15:53:37 at org.jenkinsci.plugins.workflow.cps.CpsStepContext$3.onSuccess(CpsStepContext.java:547)15:53:37 at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution$5$1.run(CpsFlowExecution.java:928)15:53:37 at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$1.run(CpsVmExecutorService.java:38)15:53:37 at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)15:53:37 at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)15:53:37 at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139)15:53:37 at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:30)15:53:37 at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:70)15:53:37 at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)15:53:37 at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)15:53:37 at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)15:53:37 at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)15:53:37 at java.base/java.lang.Thread.run(Thread.java:829)
       

      Could you please make it serializable

      Attachments

        Activity

          drulli Ulli Hafner added a comment -

          How do you use the `IssueApi` class in your tests? This class is not intended to be saved. 

          drulli Ulli Hafner added a comment - How do you use the `IssueApi` class in your tests? This class is not intended to be saved. 
          mehmet_sap Mehmet added a comment - - edited

          Hi Ulli,

           

          in my pipeline I have 7 parallel processes which calls the method scanForIssues tool: checkStyle(pattern: "...") for different issues in different systems. I check the return value of the method scanForIssues if some issue includes the severity == "ERROR" and then I send an e-mail out if its so. To avoid this issue we have set a lock but still the sometimes the issue java.io.NotSerializableException: io.jenkins.plugins.analysis.core.restapi.IssueApi occurs.

           

          Code-Snippet (this method is called parallel):

           

          void setStageStatus(String systemName, String client) {
              // lock step for get rid of serialization issue (but still the serializable issue occurs sometimes) 
              lock(resource: "*Reporting") {
                  def isUnstable = false
                  def errorMessages = ""
                  sleep 20 //Ensure that previous lock holder has time to exit and save state
                  //Entering critical phase: A serialization of the current context will fail
                  def annotatedReport = scanForIssues tool: checkStyle(pattern: "atc-checkstyle-${systemName}-${client}.xml")
                  if(annotatedReport.size() > 0) {
                      def issues = annotatedReport.getIssues()
                      issues.each { val -> 
                          if (val.getSeverity().toUpperCase() == "ERROR") {
                              isUnstable = true
                              errorMessages += "<hr>File Name: <ul><li>${val.getFileName()}</li></ul>  \nError Message: <ul><li>${val.getMessage()}</li></ul>\n\n"
                          }
                      }
                  }

                  if(isUnstable) {
                      def emailReceivers = "<some email revceivers>"
                      def subjectText = "[UNSTABLE ATC Build]: The following System has Prio 1 OR Prio 2 ATC findings: ${systemName}"
                      def bodyText = "<pre>ATC System ${systemName} has ATC findings which needs your attention. Please check the ATC findings in the systems ${systemName} and correct these:\n\n${errorMessages}</pre>"
                      emailext body: bodyText, subject: subjectText, to: emailReceivers
                      unstable("System ${systemName} has ATC findings which needs your attention. Please check the ATC findings in the system ${systemName} and correct these")
                  }
                  //Leaving critical phase
              }
          }

          mehmet_sap Mehmet added a comment - - edited Hi Ulli,   in my pipeline I have 7 parallel processes which calls the method scanForIssues tool: checkStyle(pattern: "...") for different issues in different systems. I check the return value of the method scanForIssues if some issue includes the severity == "ERROR" and then I send an e-mail out if its so. To avoid this issue we have set a lock but still the sometimes the issue java.io.NotSerializableException: io.jenkins.plugins.analysis.core.restapi.IssueApi occurs.   Code-Snippet (this method is called parallel):   void setStageStatus(String systemName, String client) {     // lock step for get rid of serialization issue (but still the serializable issue occurs sometimes)      lock(resource: "*Reporting") {         def isUnstable = false         def errorMessages = ""         sleep 20 //Ensure that previous lock holder has time to exit and save state         //Entering critical phase: A serialization of the current context will fail         def annotatedReport = scanForIssues tool: checkStyle(pattern: "atc-checkstyle-${systemName}-${client}.xml")         if(annotatedReport.size() > 0) {             def issues = annotatedReport.getIssues()             issues.each { val ->                  if (val.getSeverity().toUpperCase() == "ERROR") {                     isUnstable = true                     errorMessages += "<hr>File Name: <ul><li>${val.getFileName()}</li></ul>  \nError Message: <ul><li>${val.getMessage()}</li></ul>\n\n"                 }             }         }         if(isUnstable) {             def emailReceivers = "<some email revceivers>"             def subjectText = " [UNSTABLE ATC Build] : The following System has Prio 1 OR Prio 2 ATC findings: ${systemName}"             def bodyText = "<pre>ATC System ${systemName} has ATC findings which needs your attention. Please check the ATC findings in the systems ${systemName} and correct these:\n\n${errorMessages}</pre>"             emailext body: bodyText, subject: subjectText, to: emailReceivers             unstable("System ${systemName} has ATC findings which needs your attention. Please check the ATC findings in the system ${systemName} and correct these")         }         //Leaving critical phase     } }
          drulli Ulli Hafner added a comment -

          Thanks for adding some more details. I still do not understand why this happens as the API object is not even a member of a serialized class and will be created and disposed on the fly: https://github.com/jenkinsci/warnings-ng-plugin/blob/5ca5a1b9531b53f53ef7c13d5a30fe0cab36d80d/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/IssuesDetail.java#L216 

          Are you storing an instance in one of your scripts?

          However, changing the API to make it serializable should not hurt. So feel free to submit a PR.

           

          drulli Ulli Hafner added a comment - Thanks for adding some more details. I still do not understand why this happens as the API object is not even a member of a serialized class and will be created and disposed on the fly: https://github.com/jenkinsci/warnings-ng-plugin/blob/5ca5a1b9531b53f53ef7c13d5a30fe0cab36d80d/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/IssuesDetail.java#L216   Are you storing an instance in one of your scripts? However, changing the API to make it serializable should not hurt. So feel free to submit a PR.  
          mehmet_sap Mehmet added a comment -

          The script stores the instance in the variables "annotatedReport" & "issues" for a short period of time.

          Due to the parallel processing it might happen that the jenkins persists the current pipeline state at any time when one of the parallel threads finishes. 

          mehmet_sap Mehmet added a comment - The script stores the instance in the variables "annotatedReport" & "issues" for a short period of time. Due to the parallel processing it might happen that the jenkins persists the current pipeline state at any time when one of the parallel threads finishes. 
          drulli Ulli Hafner added a comment -

          The script stores the instance in the variables "annotatedReport" & "issues" for a short period of time.

          Due to the parallel processing it might happen that the jenkins persists the current pipeline state at any time when one of the parallel threads finishes. 

          Yes, but these instances are serializable. I wonder why an instance of io.jenkins.plugins.analysis.core.restapi.IssueApi is problematic, these instances are generated on the fly to provide access to the remote API.

          drulli Ulli Hafner added a comment - The script stores the instance in the variables "annotatedReport" & "issues" for a short period of time. Due to the parallel processing it might happen that the jenkins persists the current pipeline state at any time when one of the parallel threads finishes.  Yes, but these instances are serializable. I wonder why an instance of io.jenkins.plugins.analysis.core.restapi.IssueApi is problematic, these instances are generated on the fly to provide access to the remote API.

          People

            Unassigned Unassigned
            mehmet_sap Mehmet
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: