> Am 17.11.2021 um 14:42 schrieb 'Jesse Glick' via Jenkins Developers > <[email protected]>: > > On Wed, Nov 17, 2021 at 5:57 AM Ullrich Hafner <[email protected] > <mailto:[email protected]>> wrote: > […] is stored in a CopyOnWriteArrayList. If your background thread serializes > my instance during the loop it can happen that the loop variable is already > set, but the list with the results is not. > > Hard to follow what you are saying without a code reference, but a > `CopyOnWriteArrayList` is designed to be safe to save from another thread; > that is its whole purpose. > > I need some lock around the whole block of variables > > Block of fields? Again hard to discuss without a concrete example, but in > general if there is a block of data that should be replaced atomically, best > to keep it all in its own object with `final` fields, and refer to that one > object with a `volatile` field. >
Actually I do not have fields anymore in the step: https://github.com/jenkinsci/warnings-ng-plugin/blob/089ad6c3aac292bc926503e644b892371f609e88/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/ScanForIssuesStep.java#L205-L215 <https://github.com/jenkinsci/warnings-ng-plugin/blob/089ad6c3aac292bc926503e644b892371f609e88/plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/ScanForIssuesStep.java#L205-L215> As far as I understood the problem in JENKINS-67145 <https://issues.jenkins.io/browse/JENKINS-67145> my step is somehow serialized during the execution in lines 205-215. Or can I view the code in a step as an atomic unit? > -- > 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 [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr0ouBxhg1arOFwosdrit-O9WdBeiiAbgSAA00%3DPnbBkPQ%40mail.gmail.com > > <https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr0ouBxhg1arOFwosdrit-O9WdBeiiAbgSAA00%3DPnbBkPQ%40mail.gmail.com?utm_medium=email&utm_source=footer>. -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/80549ED3-122A-49E6-9327-0B2D3A376EB9%40gmail.com.
