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

Fix ConcurrentModificationException in PlotBuildAction class

    Details

    • Similar Issues:

      Description

      Background

      New class called PlotBuildAction was added when compatibility with Pipeline plugin was implemented in https://github.com/jenkinsci/plot-plugin/pull/32.
      Seems like this class current implementation is not thread safe and user reported 1st time issue with ConcurrentModificationException in PR comment. Exception was not reproducible to me even though I used provided by reporter Jenkins & Pipeline configurations.
      There was an attempt to blindly fix the issue in commit, but it didn't work out.
      Second report about the same exception appeared recently.

      Sam Van Oort proposed copy-on-write approach rather than synchronized for methods. It should be considered as potential fix.

      Environment

      What should be done

      • We need to reproduce ConcurrentModificationException while accessing plots array in PlotBuildAction and fix it.
      • It's good to have a test for the fix

      How to test

        Attachments

          Activity

          vgaidarji Veaceslav Gaidarji created issue -
          vgaidarji Veaceslav Gaidarji made changes -
          Field Original Value New Value
          Description h3. Background

          New class called [PlotBuildAction|https://github.com/jenkinsci/plot-plugin/blob/eb0f1ae3fdb48d5299ea04c93b445f445c0443dc/src/main/java/hudson/plugins/plot/PlotBuildAction.java] was added when compatibility with Pipeline plugin was implemented in https://github.com/jenkinsci/plot-plugin/pull/32.
          Seems like this class current implementation is not thread safe and user reported 1st time issue with ConcurrentModificationException in [PR comment|https://github.com/jenkinsci/plot-plugin/pull/32#issuecomment-335386273]. Exception was not reproducible to me even though I used provided by reporter Jenkins & Pipeline configurations.
          There was an attempt to blindly fix the issue in [commit|https://github.com/jenkinsci/plot-plugin/commit/35aaac24ae9b41136baa2a9dfb28aaee1c9e745b], but it didn't work out.
          [Second report|https://github.com/jenkinsci/plot-plugin/pull/32#commitcomment-25981039] about the same exception appeared recently.

          [~svanoort] proposed [copy-on-write approach|https://github.com/jenkinsci/plot-plugin/pull/32#discussion_r146071666] rather than synchronized for methods. It should be considered as potential fix.


          h3. What should be done

          - We need to reproduce ConcurrentModificationException while accessing plots array in [PlotBuildAction|https://github.com/jenkinsci/plot-plugin/blob/eb0f1ae3fdb48d5299ea04c93b445f445c0443dc/src/main/java/hudson/plugins/plot/PlotBuildAction.java] and fix it.
          - It's good to have a test for the fix

          h3. How to test

          - If issue is reproducible, test should be written
          - Gather feedback from https://github.com/dolfinsbizou and https://github.com/shawnhines as they reported about this exception and can verify on their environments
          h3. Background

          New class called [PlotBuildAction|https://github.com/jenkinsci/plot-plugin/blob/eb0f1ae3fdb48d5299ea04c93b445f445c0443dc/src/main/java/hudson/plugins/plot/PlotBuildAction.java] was added when compatibility with Pipeline plugin was implemented in [https://github.com/jenkinsci/plot-plugin/pull/32].
          Seems like this class current implementation is not thread safe and user reported 1st time issue with ConcurrentModificationException in [PR comment|https://github.com/jenkinsci/plot-plugin/pull/32#issuecomment-335386273]. Exception was not reproducible to me even though I used provided by reporter Jenkins & Pipeline configurations.
          There was an attempt to blindly fix the issue in [commit|https://github.com/jenkinsci/plot-plugin/commit/35aaac24ae9b41136baa2a9dfb28aaee1c9e745b], but it didn't work out.
           [Second report|https://github.com/jenkinsci/plot-plugin/pull/32#commitcomment-25981039] about the same exception appeared recently.

          [~svanoort] proposed [copy-on-write approach|https://github.com/jenkinsci/plot-plugin/pull/32#discussion_r146071666] rather than synchronized for methods. It should be considered as potential fix.
          h3. Environment
           - Plot plugin version is [1.2.0|https://github.com/jenkinsci/plot-plugin/releases/tag/plot-2.0.0].
           - [Environment|https://github.com/jenkinsci/plot-plugin/pull/32#issuecomment-339016012].

          h3. What should be done
           - We need to reproduce ConcurrentModificationException while accessing plots array in [PlotBuildAction|https://github.com/jenkinsci/plot-plugin/blob/eb0f1ae3fdb48d5299ea04c93b445f445c0443dc/src/main/java/hudson/plugins/plot/PlotBuildAction.java] and fix it.
           - It's good to have a test for the fix

          h3. How to test
           - If issue is reproducible, test should be written
           - Gather feedback from [https://github.com/dolfinsbizou] and [https://github.com/shawnhines] as they reported about this exception and can verify on their environments
          Hide
          vgaidarji Veaceslav Gaidarji added a comment - - edited

          Similar issues:

          Not sure yet how to reproduce the CME, gathering more info from similar issues and trying to reproduce it in a test first.

          Show
          vgaidarji Veaceslav Gaidarji added a comment - - edited Similar issues: https://issues.jenkins-ci.org/browse/JENKINS-42720 https://issues.jenkins-ci.org/browse/JENKINS-44597 https://issues.jenkins-ci.org/browse/JENKINS-19561   https://issues.jenkins-ci.org/browse/JENKINS-34313   Not sure yet how to reproduce the CME, gathering more info from similar issues and trying to reproduce it in a test first.
          vgaidarji Veaceslav Gaidarji made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          vgaidarji Veaceslav Gaidarji made changes -
          Status In Progress [ 3 ] In Review [ 10005 ]
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Veaceslav Gaidarji
          Path:
          src/main/java/hudson/plugins/plot/PlotBuildAction.java
          src/test/java/hudson/plugins/plot/PlotBuildActionTest.java
          http://jenkins-ci.org/commit/plot-plugin/56fc2182807a04a763844f8bbb1b7ca3109d1d78
          Log:
          Merge pull request #40 from jenkinsci/JENKINS-48465-fix-concurrent-modification-exception

          JENKINS-48465 Fix ConcurrentModificationException in PlotBuildAction

          Compare: https://github.com/jenkinsci/plot-plugin/compare/490c98c4544f...56fc2182807a

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Veaceslav Gaidarji Path: src/main/java/hudson/plugins/plot/PlotBuildAction.java src/test/java/hudson/plugins/plot/PlotBuildActionTest.java http://jenkins-ci.org/commit/plot-plugin/56fc2182807a04a763844f8bbb1b7ca3109d1d78 Log: Merge pull request #40 from jenkinsci/ JENKINS-48465 -fix-concurrent-modification-exception JENKINS-48465 Fix ConcurrentModificationException in PlotBuildAction Compare: https://github.com/jenkinsci/plot-plugin/compare/490c98c4544f...56fc2182807a
          vgaidarji Veaceslav Gaidarji made changes -
          Status In Review [ 10005 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Hide
          vgaidarji Veaceslav Gaidarji added a comment -

          Fix included in 2.0.2 release. 

          Show
          vgaidarji Veaceslav Gaidarji added a comment - Fix included in 2.0.2 release. 

            People

            • Assignee:
              vgaidarji Veaceslav Gaidarji
              Reporter:
              vgaidarji Veaceslav Gaidarji
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: