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

Optional extensions are not picked up after installing the optional dependency

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Minor
    • Resolution: Fixed
    • core
    • None

    Description

      Problem statement

      Consider plugins A and B.

      A has an optional dependency to B.

      B exposes an extension point called B.

      A contains an @Extension(optional=true) or an @OptionalExtension(requiresPlugins = "B") (when using the variant plugin)
      and has public class A extends B.

      • Set up a new Jenkins instance
      • Install plugin A
      • Install plugin B
      • Check groovy console ExtensionList.lookup(B.class)
      • An empty list is returned. Expected to see class A singleton.

      After restarting the Jenkins instance, class A singleton is listed properly.

      Prior/related work

      Attachments

        Issue Links

          Activity

            vlatombe Vincent Latombe created issue -
            vlatombe Vincent Latombe made changes -
            Field Original Value New Value
            Description h1. Problem statement
            Consider plugin A and B. A has an optional dependency to B.

            B exposes an extension point called B

            A contains an {{@Extension(optional=true)}} or an {{@OptionalExtension(requiresPlugins = "B")}} (when using the [variant plugin|https://github.com/jenkinsci/variant-plugin])
            and has {{public class A extends B}}.

            * Set up a new Jenkins instance
            * Install plugin A
            * Install plugin B
            * Check groovy console ExtensionList.lookup(B.class)
            * An empty list is returned. Expected to see class A singleton.

            After restarting the Jenkins instance, class A singleton is listed properly.

            h1. Prior/related work
            * JENKINS-19976 fixed classloading in this kind of situation
            * JENKINS-19508 is proposing to eliminate this use case altogether
            * JENKINS-49026 is a consequence of this problem
            h1. Problem statement
            Consider plugin A and B.

            A has an optional dependency to B.

            B exposes an extension point called B.

            A contains an {{@Extension(optional=true)}} or an {{@OptionalExtension(requiresPlugins = "B")}} (when using the [variant plugin|https://github.com/jenkinsci/variant-plugin])
            and has {{public class A extends B}}.

            * Set up a new Jenkins instance
            * Install plugin A
            * Install plugin B
            * Check groovy console ExtensionList.lookup(B.class)
            * An empty list is returned. Expected to see class A singleton.

            After restarting the Jenkins instance, class A singleton is listed properly.

            h1. Prior/related work
            * JENKINS-19976 fixed classloading in this kind of situation
            * JENKINS-19508 is proposing to eliminate this use case altogether
            * JENKINS-49026 is a consequence of this problem
            vlatombe Vincent Latombe made changes -
            Description h1. Problem statement
            Consider plugin A and B.

            A has an optional dependency to B.

            B exposes an extension point called B.

            A contains an {{@Extension(optional=true)}} or an {{@OptionalExtension(requiresPlugins = "B")}} (when using the [variant plugin|https://github.com/jenkinsci/variant-plugin])
            and has {{public class A extends B}}.

            * Set up a new Jenkins instance
            * Install plugin A
            * Install plugin B
            * Check groovy console ExtensionList.lookup(B.class)
            * An empty list is returned. Expected to see class A singleton.

            After restarting the Jenkins instance, class A singleton is listed properly.

            h1. Prior/related work
            * JENKINS-19976 fixed classloading in this kind of situation
            * JENKINS-19508 is proposing to eliminate this use case altogether
            * JENKINS-49026 is a consequence of this problem
            h1. Problem statement
            Consider plugins *A* and *B*.

            *A* has an optional dependency to *B*.

            *B* exposes an extension point called B.

            *A* contains an {{@Extension(optional=true)}} or an {{@OptionalExtension(requiresPlugins = "B")}} (when using the [variant plugin|https://github.com/jenkinsci/variant-plugin])
            and has {{public class A extends B}}.

            * Set up a new Jenkins instance
            * Install plugin *A*
            * Install plugin *B*
            * Check groovy console {{ExtensionList.lookup(B.class)}}
            * An empty list is returned. Expected to see class *A* singleton.

            After restarting the Jenkins instance, class *A* singleton is listed properly.

            h1. Prior/related work
            * JENKINS-19976 fixed classloading in this kind of situation
            * JENKINS-19508 is proposing to eliminate this use case altogether
            * JENKINS-49026 is a consequence of this problem
            vlatombe Vincent Latombe made changes -
            Link This issue relates to JENKINS-19508 [ JENKINS-19508 ]
            vlatombe Vincent Latombe made changes -
            Link This issue relates to JENKINS-19976 [ JENKINS-19976 ]
            vlatombe Vincent Latombe made changes -
            Link This issue relates to JENKINS-49026 [ JENKINS-49026 ]
            vlatombe Vincent Latombe made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            vlatombe Vincent Latombe made changes -
            Assignee Vincent Latombe [ vlatombe ]
            vlatombe Vincent Latombe made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            vlatombe Vincent Latombe made changes -
            Remote Link This issue links to "Core PR #3370 (Web Link)" [ 20320 ]
            jamesdumay James Dumay made changes -
            Remote Link This issue links to "CloudBees Internal TIGER-4517 (Web Link)" [ 20556 ]

            Code changed in jenkins
            User: Vincent Latombe
            Path:
            core/src/main/java/hudson/ExtensionFinder.java
            core/src/main/java/hudson/PluginManager.java
            test/src/test/java/hudson/PluginManagerTest.java
            test/src/test/resources/plugins/jenkins-50336.hpi
            test/src/test/resources/plugins/variant.hpi
            http://jenkins-ci.org/commit/jenkins/8c1b8b8e144280f9645eaf761ed7f5e894ac7353
            Log:
            JENKINS-50336 Fix loading optional extensions after installing a missing dependency (#3370)

            • JENKINS-50336 Only keep extensions that could be loaded in memory

            So that delta computations will re-attempt to load any extension that
            previously failed or was skipped after a new plugin is installed.

            After installing a plugin, need to refresh extensions in order to pick
            up extensions that can be loaded thanks to this new plugin.

            • JENKINS-50336 @OptionalExtension annotated classes were not being picked up after dynamic load of variant

            Recompute GuiceExtensionAnnotation list when refreshing extensions

            *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_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Vincent Latombe Path: core/src/main/java/hudson/ExtensionFinder.java core/src/main/java/hudson/PluginManager.java test/src/test/java/hudson/PluginManagerTest.java test/src/test/resources/plugins/jenkins-50336.hpi test/src/test/resources/plugins/variant.hpi http://jenkins-ci.org/commit/jenkins/8c1b8b8e144280f9645eaf761ed7f5e894ac7353 Log: JENKINS-50336 Fix loading optional extensions after installing a missing dependency (#3370) JENKINS-50336 Only keep extensions that could be loaded in memory So that delta computations will re-attempt to load any extension that previously failed or was skipped after a new plugin is installed. After installing a plugin, need to refresh extensions in order to pick up extensions that can be loaded thanks to this new plugin. JENKINS-50336 @OptionalExtension annotated classes were not being picked up after dynamic load of variant Recompute GuiceExtensionAnnotation list when refreshing extensions * 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 Oleg Nenashev added a comment -

            Fixed in 2.127.
            danielbeck vlatombe It is categorized as RFE, and I do not consider it as backportable. Are you fine with that?

            oleg_nenashev Oleg Nenashev added a comment - Fixed in 2.127. danielbeck vlatombe It is categorized as RFE, and I do not consider it as backportable. Are you fine with that?
            oleg_nenashev Oleg Nenashev made changes -
            Resolution Fixed [ 1 ]
            Status In Review [ 10005 ] Resolved [ 5 ]
            danielbeck Daniel Beck added a comment -

            Does not qualify for backporting IMO.

            danielbeck Daniel Beck added a comment - Does not qualify for backporting IMO.

            Fine for me.

            vlatombe Vincent Latombe added a comment - Fine for me.
            jglick Jesse Glick made changes -
            Link This issue relates to JENKINS-14392 [ JENKINS-14392 ]

            People

              vlatombe Vincent Latombe
              vlatombe Vincent Latombe
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: