Skip to content

Commit

Permalink
[JENKINS-72622] Address SpotBugs warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Dohbedoh committed May 15, 2024
1 parent 4167549 commit 970d0c6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/src/main/java/jenkins/agents/CloudSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,11 @@ private void handleNewCloudPage(Descriptor<Cloud> descriptor, String name, Stapl
public synchronized void doDoCreate(StaplerRequest req, StaplerResponse rsp,
@QueryParameter String cloudDescriptorName) throws IOException, ServletException, Descriptor.FormException {
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
Cloud cloud = Cloud.all().findByName(cloudDescriptorName).newInstance(req, req.getSubmittedForm());
Descriptor<Cloud> cloudDescriptor = Cloud.all().findByName(cloudDescriptorName);
if (cloudDescriptor == null) {
throw new Failure(String.format("No cloud descriptor found for %s", cloudDescriptorName));
}
Cloud cloud = cloudDescriptor.newInstance(req, req.getSubmittedForm());
if (!Jenkins.get().clouds.add(cloud)) {
LOGGER.log(Level.WARNING, () -> "Creating duplicate cloud name " + cloud.name + ". Plugin " + Jenkins.get().getPluginManager().whichPlugin(cloud.getClass()) + " should be updated to support user provided name.");
}
Expand Down

0 comments on commit 970d0c6

Please sign in to comment.