The CPS VM thread is responsible for saving the Pipeline's execution state, so if you are using a non-blocking step execution (and it looks like you are <https://github.com/jenkinsci/warnings-ng-plugin/blob/e6f0b7a542d4f10c71b93925eba83e20d7caa95b/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/AnalysisExecution.java#L26>), it is possible that your step is executing on a background thread while the Pipeline program is being saved on the CPS VM thread. You should account for this in any mutable data reachable from non-blocking step executions that is part of the execution's serialized state, for example by using CopyOnWriteArrayList, replacing fields rather than mutating them, using writeReplace, etc.
The exception in the Jira ticket suggests that one of the objects inside of one of the AnnotatedReport instances returned by a scanIssues step, which is stored a local variable in the user's Pipeline, is being modified. Perhaps the issue is that there is a filename match in the FileStatistics between the issues collected by the user's different parallel branches, so when this code <https://github.com/jenkinsci/forensics-api-plugin/blob/d0dc4ec448ca6c9a0d5ce8a6d39e238ba07e8c30/src/main/java/io/jenkins/plugins/forensics/miner/RepositoryStatistics.java#L242> runs for the first time inside of AnnotatedReport.addAll in PublishIssuesStep.Execution.Run it uses the exact FileStatistics instance from an existing AnnotatedReport instance, but when it runs after that it modifies the previous FileStatistics instance here <https://github.com/jenkinsci/forensics-api-plugin/blob/d0dc4ec448ca6c9a0d5ce8a6d39e238ba07e8c30/src/main/java/io/jenkins/plugins/forensics/miner/RepositoryStatistics.java#L256>, and then since the FileStatistics instance is also reachable via one of the AnnotatedReport local variables in the Pipeline you have a potential ConcurrentModificationError depending on the serialization timing. On Tue, Nov 16, 2021 at 8:09 AM Ullrich Hafner <ullrich.haf...@gmail.com> wrote: > As far as I understand the concept of CPS pipelines, steps may be > serialized to disk during runtime if the durability level is set to > MAX_SURVIVABILITY. It seems that one of my steps causes a > ConcurrentModificationException while the step’s memory is written to disk > and in parallel the fields (or local variables?) are modified by my step > (see [1] for the bug report). Is there anything I need to do in my plugin > to avoid such problems? > > [1] https://issues.jenkins.io/browse/JENKINS-67145 > > -- > You received this message because you are subscribed to the Google Groups > "Jenkins Developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to jenkinsci-dev+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jenkinsci-dev/6F19E406-45C9-4D4F-82C9-D2712E996199%40gmail.com > . > -- You received this message because you are subscribed to the Google Groups "Jenkins Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAF73ShAM%2ByRivnQBcW7XegcvKRjbHFCH5haF%3D2afOkYuP-tsig%40mail.gmail.com.