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

PluginFirstClassLoaders don't work with GroovyClassLoader.loadClass for .groovy files

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: core
    • Labels:
      None
    • Similar Issues:

      Description

      This was uncovered in the context of https://github.com/jenkinsci/kubernetes-plugin/pull/127 - PluginFirstClassLoader.findResource always returns null, which seems to result in CpsScript.getClass().getClassLoader().loadClass("some.class.in.resources.groovy") failing (for that matter, UberClassLoader.findResource("some/file/from/a/PluginFirstClassLoader") always returns null, which I'm guessing is the problem). Needs more investigation to figure out exactly what's happening here.

        Attachments

          Issue Links

            Activity

            Hide
            abayer Andrew Bayer added a comment -

            I've got a PR up adding a findResource override to PluginFirstClassLoader, which does resolve the original problem, but the PR still needs tests.

            Show
            abayer Andrew Bayer added a comment - I've got a PR up adding a findResource override to PluginFirstClassLoader , which does resolve the original problem, but the PR still needs tests.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            core/src/main/java/hudson/ClassicPluginStrategy.java
            core/src/main/java/hudson/PluginFirstClassLoader.java
            core/src/main/java/jenkins/util/AntWithFindResourceClassLoader.java
            test/src/test/java/hudson/PluginManagerTest.java
            test/src/test/resources/plugins/plugin-first.hpi
            http://jenkins-ci.org/commit/jenkins/303a9f7df70b702dfa3df1fa5bdf0a2afe9b1445
            Log:
            [FIXED JENKINS-44898] Add findResource to PluginFirstClassLoader (#2916)

            • [FIXED JENKINS-44898] Add findResource to PluginFirstClassLoader

            This fixes GroovyClassLoader.loadClass for a .groovy file in a plugin
            with a PluginFirstClassLoader, specifically by fixing fast-loading via
            the UberClassLoader.

            • Move common code to AntWithFindResourceClassLoader.
            • Adding testing of new PluginFirstClassLoader behavior.
            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: core/src/main/java/hudson/ClassicPluginStrategy.java core/src/main/java/hudson/PluginFirstClassLoader.java core/src/main/java/jenkins/util/AntWithFindResourceClassLoader.java test/src/test/java/hudson/PluginManagerTest.java test/src/test/resources/plugins/plugin-first.hpi http://jenkins-ci.org/commit/jenkins/303a9f7df70b702dfa3df1fa5bdf0a2afe9b1445 Log: [FIXED JENKINS-44898] Add findResource to PluginFirstClassLoader (#2916) [FIXED JENKINS-44898] Add findResource to PluginFirstClassLoader This fixes GroovyClassLoader.loadClass for a .groovy file in a plugin with a PluginFirstClassLoader, specifically by fixing fast-loading via the UberClassLoader. Move common code to AntWithFindResourceClassLoader. Adding testing of new PluginFirstClassLoader behavior.
            Hide
            danielbeck Daniel Beck added a comment -

            Unclear whether this is safe enough for backporting, but nominating anyway.

            Show
            danielbeck Daniel Beck added a comment - Unclear whether this is safe enough for backporting, but nominating anyway.
            Hide
            danielbeck Daniel Beck added a comment -

            Fixed in core 2.66.

            Show
            danielbeck Daniel Beck added a comment - Fixed in core 2.66.

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                abayer Andrew Bayer
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: