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

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

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • core
    • None

      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.

          [JENKINS-44898] PluginFirstClassLoaders don't work with GroovyClassLoader.loadClass for .groovy files

          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.

          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.

          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.

          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.

          Daniel Beck added a comment -

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

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

          Daniel Beck added a comment -

          Fixed in core 2.66.

          Daniel Beck added a comment - Fixed in core 2.66.

            abayer Andrew Bayer
            abayer Andrew Bayer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: