Skip to content

Commit

Permalink
Improved null handling in AbstractProject.<init>.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Oct 2, 2019
1 parent 5f4b878 commit a536386
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 2 additions & 3 deletions core/src/main/java/hudson/model/AbstractProject.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,8 @@ protected AbstractProject(ItemGroup parent, String name) {
buildMixIn = createBuildMixIn();
builds = buildMixIn.getRunMap();

final Jenkins j = Jenkins.get();
final List<Node> nodes = j != null ? j.getNodes() : null;
if(nodes!=null && !nodes.isEmpty()) {
Jenkins j = Jenkins.getInstanceOrNull();
if (j != null && !j.getNodes().isEmpty()) {
// if a new job is configured with Hudson that already has agent nodes
// make it roamable by default
canRoam = true;
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/jenkins/model/Jenkins.java
Original file line number Diff line number Diff line change
Expand Up @@ -2096,6 +2096,7 @@ protected Map<Node,Computer> getComputerMap() {
* Returns all {@link Node}s in the system, excluding {@link Jenkins} instance itself which
* represents the master.
*/
@Nonnull
public List<Node> getNodes() {
return nodes.getNodes();
}
Expand Down

0 comments on commit a536386

Please sign in to comment.