Skip to content

Commit

Permalink
Null safety for createProject (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtnord authored Apr 19, 2024
2 parents 7c78021 + 46e2e04 commit 42bbc0a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/java/com/cloudbees/hudson/plugins/folder/Folder.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

package com.cloudbees.hudson.plugins.folder;

import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.CopyOnWrite;
import hudson.Extension;
import hudson.Util;
Expand Down Expand Up @@ -270,15 +271,16 @@ public TopLevelItem createProjectFromXML(String name, InputStream xml) throws IO
return nue;
}

public <T extends TopLevelItem> T createProject(Class<T> type, String name) throws IOException {
return type.cast(createProject((TopLevelItemDescriptor) Jenkins.get().getDescriptor(type), name));
public <T extends TopLevelItem> T createProject(@NonNull Class<T> type, @NonNull String name) throws IOException {
return type.cast(createProject((TopLevelItemDescriptor) Jenkins.get().getDescriptorOrDie(type), name));
}

public TopLevelItem createProject(TopLevelItemDescriptor type, String name) throws IOException {
public TopLevelItem createProject(@NonNull TopLevelItemDescriptor type, @NonNull String name) throws IOException {
return createProject(type, name, true);
}

public TopLevelItem createProject(TopLevelItemDescriptor type, String name, boolean notify) throws IOException {
@Override
public TopLevelItem createProject(@NonNull TopLevelItemDescriptor type, @NonNull String name, boolean notify) throws IOException {
if (!isAllowedChildDescriptor(type)) {
throw new IOException("forbidden child type");
}
Expand Down

0 comments on commit 42bbc0a

Please sign in to comment.