jenkinsci / nomad-plugin

Nomad cloud plugin for Jenkins
https://plugins.jenkins.io/nomad/
MIT License
56 stars 41 forks source link

NomadCloud's private "name" field shadows its public parent and produces NullPointerException in other plugins #38

Closed multani closed 5 years ago

multani commented 5 years ago

NomadCloud redefines the name attribute as a private, whereas the parent class (via AbastractCloudImpl) defines it as public.

This creates a situation where:

  1. When Jenkins starts, it picks up the configuration from its configuration file
  2. It loads the relevant Clouds objects configured and deserialize somehow the configuration into these objects
  3. This populate the private name field of the concrete NomadCloud object, and shadows the public name field of the parent class
  4. There's now a situation where, considering we have a cloud object of type NomadCloud:
    • cloud.name is null (it's the public name field of the parent class)
    • cloud.getName() returns the actual name of the NomadCloud object

This triggers unrelated failures many other Cloud-like plugins which are calling the public Jenkins.CloudList.getByName() method because the name field is now null and c.name.equals(name) raises a NullPointerException.

phedoreanu commented 5 years ago

@multani please review?