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

Items reported twice via ItemGroup /api on JDK 8 (and JDK 7u80+)

    Details

    • Type: Bug
    • Status: In Progress (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Component/s: core
    • Labels:
    • Similar Issues:

      Description

      Exported API reports all jobs twice. It only seem to affect jobs scoped to jenkins.

      $JENKINS_URL/api/xml:

      <hudson>
        <assignedLabel/>
        <mode>NORMAL</mode>
        <nodeDescription>the master Jenkins node</nodeDescription>
        <nodeName/>
        <numExecutors>2</numExecutors>
        <job>
          <name>bash</name>
          <url>http://localhost:8080/job/bash/</url>
          <color>blue</color>
        </job>
        <job>
          <name>bash</name>
          <url>http://localhost:8080/job/bash/</url>
          <color>blue</color>
        </job>
        <overallLoad/>
        <primaryView>
          <name>All</name>
          <url>http://localhost:8080/</url>
        </primaryView>
        <quietingDown>false</quietingDown>
        <slaveAgentPort>0</slaveAgentPort>
        <unlabeledLoad/>
        <useCrumbs>false</useCrumbs>
        <useSecurity>false</useSecurity>
        <view>
        <name>All</name>
        <url>http://localhost:8080/</url>
        </view>
      </hudson>
      

      It works correctly when jenkins is build with java 7 and run on either 7 or 8. Though it is present when build with java 8 (and run on either 7 or 8). This is reproduced by hudson.model.ApiTest.wrappedMultipleItems. Tested on OpenJDK 1.7.0_75 and OpenJDK 1.8.0_31.

        Attachments

          Issue Links

            Activity

            Hide
            olivergondza Oliver Gondža added a comment - - edited

            Update:

            • This is reproducible in OpenJDK 1.7.0_85
            • It seems that Model found 2 properties with following signatures:
            public java.util.Collection jenkins.model.Jenkins.getItems() declared in class jenkins.model.Jenkins 
            public java.util.List jenkins.model.Jenkins.getItems() declared in class jenkins.model.Jenkins 
            

            I dare to speculate that certain JDK version returns it as 2 different methods in case the overload specifies subtype as return type (List vs. Collection).

            Show
            olivergondza Oliver Gondža added a comment - - edited Update: This is reproducible in OpenJDK 1.7.0_85 It seems that Model found 2 properties with following signatures: public java.util.Collection jenkins.model.Jenkins.getItems() declared in class jenkins.model.Jenkins public java.util.List jenkins.model.Jenkins.getItems() declared in class jenkins.model.Jenkins I dare to speculate that certain JDK version returns it as 2 different methods in case the overload specifies subtype as return type (List vs. Collection).
            Hide
            olivergondza Oliver Gondža added a comment -

            It seems that javac in case of:

            public interface ItemGroup<T extends Item> extends PersistenceRoot, ModelObject {
                Collection<T> getItems();
                ...
            }
            
            @ExportedBean
            public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLevelItemGroup, StaplerProxy, StaplerFallback, ModifiableViewGroup, AccessControlled, DescriptorByNameOwner, ModelObjectWithContextMenu, ModelObjectWithChildren {
                @Exported(name="jobs")
                public List<TopLevelItem> getItems() {
                ...
            

            generates synthetic bridge method that has all annotation copied since [1], hence causing the bug. We should either skip m.isSynthetic() && m.isBridge() (we should not need methods generated by @WithBridgeMethods) or pick only one method/field per exported name (assuming synthetic bridge method will do as well as the original for API generation).

            [1] http://bugs.java.com/view_bug.do?bug_id=6695379

            Show
            olivergondza Oliver Gondža added a comment - It seems that javac in case of: public interface ItemGroup<T extends Item> extends PersistenceRoot, ModelObject { Collection<T> getItems(); ... } @ExportedBean public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLevelItemGroup, StaplerProxy, StaplerFallback, ModifiableViewGroup, AccessControlled, DescriptorByNameOwner, ModelObjectWithContextMenu, ModelObjectWithChildren { @Exported(name="jobs") public List<TopLevelItem> getItems() { ... generates synthetic bridge method that has all annotation copied since [1] , hence causing the bug. We should either skip m.isSynthetic() && m.isBridge() (we should not need methods generated by @WithBridgeMethods ) or pick only one method/field per exported name (assuming synthetic bridge method will do as well as the original for API generation). [1] http://bugs.java.com/view_bug.do?bug_id=6695379
            Hide
            abayer Andrew Bayer added a comment -

            This is annoying the pants off of me...assigning to Kohsuke for him to investigate. =)

            Show
            abayer Andrew Bayer added a comment - This is annoying the pants off of me...assigning to Kohsuke for him to investigate. =)
            Hide
            abayer Andrew Bayer added a comment -

            Woo, just realized Oliver already fixed it and there's finally been a Stapler release with the fix in it - so, https://github.com/jenkinsci/jenkins/pull/2057

            Show
            abayer Andrew Bayer added a comment - Woo, just realized Oliver already fixed it and there's finally been a Stapler release with the fix in it - so, https://github.com/jenkinsci/jenkins/pull/2057
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            test/src/test/java/hudson/model/ApiTest.java
            http://jenkins-ci.org/commit/jenkins/e4b97c5918c06e0a40bbdbc13b1a86fa3f69ada9
            Log:
            JENKINS-26775 Suppress ApiTest.wrappedMultipleItems prior to 1.651 where it is fixed for JDK 8.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: test/src/test/java/hudson/model/ApiTest.java http://jenkins-ci.org/commit/jenkins/e4b97c5918c06e0a40bbdbc13b1a86fa3f69ada9 Log: JENKINS-26775 Suppress ApiTest.wrappedMultipleItems prior to 1.651 where it is fixed for JDK 8.

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                olivergondza Oliver Gondža
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: