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

actions from TransientActionFactories are saved in Builds.

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • core

      Actions created from a TransientActionFactory are persisted in a Run when they should never be persisted.

       

      If you have a TAF that creates an action for any ModelItem then on {{FreeStyleBuild}}s you will end up with 3 duplicate Actions displayed (and 2 will be persisted in the build.xml)

       

      One is created for the hudson.model.Queue$WaitingItem one for the hudson.model.Queue$BuildableItem and the last one for the actual build (which is the one that is not persisted).

       

      build.xml
      <?xml version='1.1' encoding='UTF-8'?>
      <build>
          <actions>
              <hudson.model.CauseAction>
                  <causeBag class="linked-hash-map">
                      <entry>
                          <hudson.model.Cause_-UserIdCause>
                              <userId>james</userId>
                          </hudson.model.Cause_-UserIdCause>
                          <int>1</int>
                      </entry>
                  </causeBag>
              </hudson.model.CauseAction>
              <com.myco.myplugin.MyAction>
                  <target>hudson.model.Queue$WaitingItem:hudson.model.FreeStyleProject@11e31cdf[free]:5</target>
              </com.myco.myplugin.MyAction>
              <com.myco.myplugin.MyAction>
                  <target>hudson.model.Queue$BuildableItem:hudson.model.FreeStyleProject@11e31cdf[free]:5</target>
              </com.myco.myplugin.MyAction>
              <jenkins.metrics.impl.TimeInQueueAction>
                  <queuingDurationMillis>9</queuingDurationMillis>
              </jenkins.metrics.impl.TimeInQueueAction>
          </actions>
          <queueId>5</queueId>
          <timestamp>1527599156095</timestamp>
          <startTime>1527599156104</startTime>
          <result>SUCCESS</result>
          <duration>3225</duration>
          <charset>windows-1252</charset>
          <keepLog>false</keepLog>
          <builtOn></builtOn>
          <workspace>C:\workarea\yplugin\work\workspace\free</workspace>
          <hudsonVersion>2.107.3</hudsonVersion>
          <scm class="hudson.scm.NullChangeLogParser"/>
          <culprits class="com.google.common.collect.EmptyImmutableSortedSet"/>
      </build>
      

       

          [JENKINS-51584] actions from TransientActionFactories are saved in Builds.

          James Nord added a comment -

          code has been there since the original introduction of TransientActionFactory. I think an over eager refactoring within the IDE was at play. It looks like there are some more iffy refactorings (but not subject to this issue / PR)

          James Nord added a comment - code has been there since the original introduction of TransientActionFactory. I think an over eager refactoring within the IDE was at play. It looks like there are some more iffy refactorings (but not subject to this issue / PR)

          Jesse Glick added a comment -

          Probably you lack context to file a fix for the weird code in TryBlueOceanMenu but could you please at least file a bug in blueocean-plugin requesting its removal with the fix of the core bug? (Or earlier, if they just cease to apply the factory overly broadly to ModelObject and actually enumerate the sensible target types.)

          Jesse Glick added a comment - Probably you lack context to file a fix for the weird code in TryBlueOceanMenu but could you please at least file a bug in blueocean-plugin requesting its removal with the fix of the core bug? (Or earlier, if they just cease to apply the factory overly broadly to ModelObject and actually enumerate the sensible target types.)

          Code changed in jenkins
          User: James Nord
          Path:
          test/src/test/java/jenkins/model/TransientActionFactoryTest.java
          http://jenkins-ci.org/commit/jenkins/cf3389f33f19c53cb5faf4c4657d95c7549272cf
          Log:
          JENKINS-51584 Added unit test showing the issue.

          The Actions are created for the hudson.model.Queue$WaitingItem and
          hudson.model.Queue$BuildableItem but get persisted in the actions list
          of the build.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: James Nord Path: test/src/test/java/jenkins/model/TransientActionFactoryTest.java http://jenkins-ci.org/commit/jenkins/cf3389f33f19c53cb5faf4c4657d95c7549272cf Log: JENKINS-51584 Added unit test showing the issue. The Actions are created for the hudson.model.Queue$WaitingItem and hudson.model.Queue$BuildableItem but get persisted in the actions list of the build.

          Code changed in jenkins
          User: James Nord
          Path:
          test/src/test/java/jenkins/model/TransientActionFactoryTest.java
          http://jenkins-ci.org/commit/jenkins/ed4c94a0a10eacc6fc5dee6783f88f216cb0017d
          Log:
          JENKINS-51584 Unit test was not quite correct.

          Calling getActions(class) will include actions froma TransientActionFactory.

          To get the correct results just call getActions() and then filter the result.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: James Nord Path: test/src/test/java/jenkins/model/TransientActionFactoryTest.java http://jenkins-ci.org/commit/jenkins/ed4c94a0a10eacc6fc5dee6783f88f216cb0017d Log: JENKINS-51584 Unit test was not quite correct. Calling getActions(class) will include actions froma TransientActionFactory. To get the correct results just call getActions() and then filter the result.

          Code changed in jenkins
          User: James Nord
          Path:
          test/src/test/java/jenkins/model/TransientActionFactoryTest.java
          http://jenkins-ci.org/commit/jenkins/5b6acd7c2cd6a1f1784f2fe8b13875bde5a54fa0
          Log:
          JENKINS-51584 Unit test was not quite correct.

          Calling getActions(class) will include actions froma TransientActionFactory.

          To get the correct results just call getActions() and then filter the result.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: James Nord Path: test/src/test/java/jenkins/model/TransientActionFactoryTest.java http://jenkins-ci.org/commit/jenkins/5b6acd7c2cd6a1f1784f2fe8b13875bde5a54fa0 Log: JENKINS-51584 Unit test was not quite correct. Calling getActions(class) will include actions froma TransientActionFactory. To get the correct results just call getActions() and then filter the result.

          Code changed in jenkins
          User: James Nord
          Path:
          test/src/test/java/jenkins/model/TransientActionFactoryTest.java
          http://jenkins-ci.org/commit/jenkins/c4215dc6ad5f974c740bed925aaba655b27e453a
          Log:
          JENKINS-51584 Improve unit test to show allocation trace.

          improve the unit test to show the allocation trace on failure.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: James Nord Path: test/src/test/java/jenkins/model/TransientActionFactoryTest.java http://jenkins-ci.org/commit/jenkins/c4215dc6ad5f974c740bed925aaba655b27e453a Log: JENKINS-51584 Improve unit test to show allocation trace. improve the unit test to show the allocation trace on failure.

          Code changed in jenkins
          User: James Nord
          Path:
          core/src/main/java/hudson/model/Queue.java
          core/src/main/java/hudson/model/queue/WorkUnitContext.java
          http://jenkins-ci.org/commit/jenkins/8ca803819bbd7f5ecaf44179680d6694999e74d4
          Log:
          JENKINS-51584 do not store actions from TransientActionFactory.

          The code was updated to use the non deprecated getAllActions() to obtain
          the list of actions, however this was persisted in the actions causing
          the actions from TransientActionFactories to be persisted in Builds.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: James Nord Path: core/src/main/java/hudson/model/Queue.java core/src/main/java/hudson/model/queue/WorkUnitContext.java http://jenkins-ci.org/commit/jenkins/8ca803819bbd7f5ecaf44179680d6694999e74d4 Log: JENKINS-51584 do not store actions from TransientActionFactory. The code was updated to use the non deprecated getAllActions() to obtain the list of actions, however this was persisted in the actions causing the actions from TransientActionFactories to be persisted in Builds.

          Code changed in jenkins
          User: James Nord
          Path:
          core/src/main/java/hudson/model/Queue.java
          core/src/main/java/hudson/model/queue/WorkUnitContext.java
          test/src/test/java/jenkins/model/TransientActionFactoryTest.java
          http://jenkins-ci.org/commit/jenkins/d4737b2b60438ce0e3cb7a8a6f26675f7c880914
          Log:
          Merge pull request #3462 from jtnord/JENKINS-51584

          JENKINS-51584 Actions from a TransientActionFactory should not be persisted

          Compare: https://github.com/jenkinsci/jenkins/compare/8872b44cc882...d4737b2b6043
          *NOTE:* This service been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/

          Functionality will be removed from GitHub.com on January 31st, 2019.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: James Nord Path: core/src/main/java/hudson/model/Queue.java core/src/main/java/hudson/model/queue/WorkUnitContext.java test/src/test/java/jenkins/model/TransientActionFactoryTest.java http://jenkins-ci.org/commit/jenkins/d4737b2b60438ce0e3cb7a8a6f26675f7c880914 Log: Merge pull request #3462 from jtnord/ JENKINS-51584 JENKINS-51584 Actions from a TransientActionFactory should not be persisted Compare: https://github.com/jenkinsci/jenkins/compare/8872b44cc882...d4737b2b6043 * NOTE: * This service been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/ Functionality will be removed from GitHub.com on January 31st, 2019.

          Oleg Nenashev added a comment -

          Fixed in 2.126

          Oleg Nenashev added a comment - Fixed in 2.126

          Code changed in jenkins
          User: James Nord
          Path:
          core/src/main/java/hudson/model/Queue.java
          core/src/main/java/hudson/model/queue/WorkUnitContext.java
          test/src/test/java/jenkins/model/TransientActionFactoryTest.java
          http://jenkins-ci.org/commit/jenkins/4f576414b544a3d78e7156e6b1d1b12ed7406455
          Log:
          Merge pull request #3462 from jtnord/JENKINS-51584

          JENKINS-51584 Actions from a TransientActionFactory should not be persisted

          (cherry picked from commit d4737b2b60438ce0e3cb7a8a6f26675f7c880914)

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: James Nord Path: core/src/main/java/hudson/model/Queue.java core/src/main/java/hudson/model/queue/WorkUnitContext.java test/src/test/java/jenkins/model/TransientActionFactoryTest.java http://jenkins-ci.org/commit/jenkins/4f576414b544a3d78e7156e6b1d1b12ed7406455 Log: Merge pull request #3462 from jtnord/ JENKINS-51584 JENKINS-51584 Actions from a TransientActionFactory should not be persisted (cherry picked from commit d4737b2b60438ce0e3cb7a8a6f26675f7c880914)

            Unassigned Unassigned
            teilo James Nord
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: