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

DescribableHelper.uninstantiate should omit default values of @DataBoundSetter fields

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • pipeline

      If given a bean from a class that has at least one @DataBoundSetter, uninstantiate should create another bean using the @DataBoundConstructor and the same constructor parameters, then compare the values of the setter fields. If any are equals to the values from the "control" bean, omit them in the map.

      This would be useful for example for omitting changelog: true from git in the snippet generator.

          [JENKINS-25779] DescribableHelper.uninstantiate should omit default values of @DataBoundSetter fields

          Jesse Glick created issue -
          Jesse Glick made changes -
          Link New: This issue is blocking JENKINS-26094 [ JENKINS-26094 ]
          Jesse Glick made changes -
          Issue Type Original: Bug [ 1 ] New: Improvement [ 4 ]
          Labels New: usability
          Priority Original: Minor [ 4 ] New: Major [ 3 ]

          Jesse Glick added a comment -

          Would also allow the special-case handling of null values in both uninstantiate and Snippetizer to be removed: in the normal case that null is actually the default value of a reference-valued field with @DataBoundSetter, the map entry would be omitted anyway; when the field actually had a non-null default, nulling it out (if the bean actually permits this) needs to be explicit in the map to make round-tripping work. When a @DataBoundConstructor parameter is null it is probably also wise to be explicit about this in the map, though the round-trip behavior in that case is unchanged.

          Jesse Glick added a comment - Would also allow the special-case handling of null values in both uninstantiate and Snippetizer to be removed: in the normal case that null is actually the default value of a reference-valued field with @DataBoundSetter , the map entry would be omitted anyway; when the field actually had a non-null default, nulling it out (if the bean actually permits this) needs to be explicit in the map to make round-tripping work. When a @DataBoundConstructor parameter is null it is probably also wise to be explicit about this in the map, though the round-trip behavior in that case is unchanged.
          Jesse Glick made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]

          Jesse Glick added a comment -

          Specifying null for a constructor parameter (which would be null by default) is actually bad, as this would suggest node(null) {} when we want node {}.

          Jesse Glick added a comment - Specifying null for a constructor parameter (which would be null by default) is actually bad, as this would suggest node(null) { } when we want node { }.
          Jesse Glick made changes -
          Remote Link New: This issue links to "PR 58 (Web Link)" [ 12122 ]

          Code changed in jenkins
          User: Jesse Glick
          Path:
          core/src/main/java/hudson/tasks/ArtifactArchiver.java
          test/src/test/java/hudson/tasks/ArtifactArchiverTest.java
          http://jenkins-ci.org/commit/jenkins/0d8ebb17c2ea2109eb8d8577029c9358b17f6074
          Log:
          JENKINS-25779 Fix an NPE when ArtifactArchiver.setAllowEmptyArchive is not explicitly called.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: core/src/main/java/hudson/tasks/ArtifactArchiver.java test/src/test/java/hudson/tasks/ArtifactArchiverTest.java http://jenkins-ci.org/commit/jenkins/0d8ebb17c2ea2109eb8d8577029c9358b17f6074 Log: JENKINS-25779 Fix an NPE when ArtifactArchiver.setAllowEmptyArchive is not explicitly called.

          dogfood added a comment -

          Integrated in jenkins_main_trunk #3979
          JENKINS-25779 Fix an NPE when ArtifactArchiver.setAllowEmptyArchive is not explicitly called. (Revision 0d8ebb17c2ea2109eb8d8577029c9358b17f6074)

          Result = SUCCESS
          Jesse Glick : 0d8ebb17c2ea2109eb8d8577029c9358b17f6074
          Files :

          • test/src/test/java/hudson/tasks/ArtifactArchiverTest.java
          • core/src/main/java/hudson/tasks/ArtifactArchiver.java

          dogfood added a comment - Integrated in jenkins_main_trunk #3979 JENKINS-25779 Fix an NPE when ArtifactArchiver.setAllowEmptyArchive is not explicitly called. (Revision 0d8ebb17c2ea2109eb8d8577029c9358b17f6074) Result = SUCCESS Jesse Glick : 0d8ebb17c2ea2109eb8d8577029c9358b17f6074 Files : test/src/test/java/hudson/tasks/ArtifactArchiverTest.java core/src/main/java/hudson/tasks/ArtifactArchiver.java

          Code changed in jenkins
          User: Jesse Glick
          Path:
          cps/src/test/java/org/jenkinsci/plugins/workflow/cps/SnippetizerTest.java
          step-api/src/test/java/org/jenkinsci/plugins/workflow/structs/DescribableHelperTest.java
          support/src/test/java/org/jenkinsci/plugins/workflow/support/steps/input/InputStepTest.java
          http://jenkins-ci.org/commit/workflow-plugin/240173e89fc5da4adfc23135ba9ae4c28b9a02d1
          Log:
          JENKINS-25779 Established test baseline of current behavior.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: cps/src/test/java/org/jenkinsci/plugins/workflow/cps/SnippetizerTest.java step-api/src/test/java/org/jenkinsci/plugins/workflow/structs/DescribableHelperTest.java support/src/test/java/org/jenkinsci/plugins/workflow/support/steps/input/InputStepTest.java http://jenkins-ci.org/commit/workflow-plugin/240173e89fc5da4adfc23135ba9ae4c28b9a02d1 Log: JENKINS-25779 Established test baseline of current behavior.

            jglick Jesse Glick
            jglick Jesse Glick
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: