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

PluginManager::addDependencies() improperly handles plugin trees

XMLWordPrintable

      The issue has been introduced in https://github.com/jenkinsci/jenkins/commit/036a8e94ed37cf851f0cafb9cb12c21e3496ed7c

      PluginManager::addDependencies() is supposed to recursively check the plugin dependency tree and to construct a list. But calls in if (dependencyURL != null) are misordered

      If pluginA depends on pluginB, which depends on pluginC...

      1) We invoke addDependencies() for pluginB if pluginA is being loaded
      2) We pass through the first iteration of the method and get into if (dependencyURL != null)
      3) We add pluginB to the list and invoke addDependencies for children ([pluginC])
      4) We enter second addDependencies() and exit on the first condition, because dependencySet already contains pluginB => we exit without adding pluginC to the dependency list

      +    protected static void addDependencies(URL hpiResUrl, String fromPath, Set<URL> dependencySet) throws URISyntaxException, MalformedURLException {
       +        if (dependencySet.contains(hpiResUrl)) {
       +            return;
       +        }
       +
       +        Manifest manifest = parsePluginManifest(hpiResUrl);
       +        String dependencySpec = manifest.getMainAttributes().getValue("Plugin-Dependencies");
       +        if (dependencySpec != null) {
       +            String[] dependencyTokens = dependencySpec.split(",");
       +
       +            for (String dependencyToken : dependencyTokens) {
       +                
       +                // dependencyUrl=...
       +
       +                if (dependencyURL != null) {
       +                    dependencySet.add(dependencyURL);
       +                    // And transitive deps...
       +                    addDependencies(dependencyURL, fromPath, dependencySet);
       +                }
       +            }
       +        }
       +    }
      

            oleg_nenashev Oleg Nenashev
            oleg_nenashev Oleg Nenashev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: