Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use spotbugs annotations instead of JSR-305 #305

Merged
merged 1 commit into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import hudson.model.Result;
import org.kohsuke.stapler.DataBoundConstructor;

import javax.annotation.CheckForNull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import java.util.Arrays;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;

import javax.annotation.CheckForNull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -56,7 +56,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import org.acegisecurity.AccessDeniedException;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.NonNull;
import jenkins.security.QueueItemAuthenticator;

public class BuildTriggerConfig implements Describable<BuildTriggerConfig> {
Expand Down Expand Up @@ -267,7 +267,7 @@ private static void iterateBuilds(AbstractProject context, String projects, SubP
* @return List of readable items, others will be skipped if {@link AccessDeniedException} happens
*/
private static <T extends Item> List<T> readableItemsFromNameList(
ItemGroup context, @Nonnull String list, @Nonnull Class<T> type) {
ItemGroup context, @NonNull String list, @NonNull Class<T> type) {
Jenkins hudson = Jenkins.get();

List<T> r = new ArrayList<>();
Expand Down Expand Up @@ -418,7 +418,7 @@ public List<QueueTaskFuture<AbstractBuild>> perform(AbstractBuild<?, ?> build, L
return Collections.emptyList();
}

private void reportSchedulingError(@Nonnull Run<?, ?> run, @Nonnull Job<?, ?> jobToTrigger, @Nonnull BuildListener listener) {
private void reportSchedulingError(@NonNull Run<?, ?> run, @NonNull Job<?, ?> jobToTrigger, @NonNull BuildListener listener) {
// Do not print details to Build Listener, they have been reported previously in #canTriggerProject()
listener.error("Skipping " + jobToTrigger.getFullName() + "...");
if (LOGGER.isLoggable(Level.CONFIG)) {
Expand Down Expand Up @@ -543,8 +543,8 @@ protected QueueTaskFuture schedule(AbstractBuild<?, ?> build, final Job project,
}

@CheckForNull
protected QueueTaskFuture schedule(@Nonnull AbstractBuild<?, ?> build, @Nonnull final Job project, int quietPeriod,
@Nonnull List<Action> list, @Nonnull TaskListener listener) throws InterruptedException, IOException {
protected QueueTaskFuture schedule(@NonNull AbstractBuild<?, ?> build, @NonNull final Job project, int quietPeriod,
@NonNull List<Action> list, @NonNull TaskListener listener) throws InterruptedException, IOException {
// TODO Once it's in core (since 1.621) and LTS is out, switch to use new ParameterizedJobMixIn convenience method
// From https://github.com/jenkinsci/jenkins/pull/1771
Cause cause = createUpstreamCause(build);
Expand Down Expand Up @@ -582,8 +582,8 @@ protected QueueTaskFuture schedule(@Nonnull AbstractBuild<?, ?> build, @Nonnull
* @return {@code true} if the project can be scheduled.
* {@code false} if there is a lack of permissions, details will be printed to the logs then.
*/
/*package*/ static boolean canTriggerProject(@Nonnull AbstractBuild<?, ?> build,
@Nonnull final Job job, @Nonnull TaskListener taskListener) {
/*package*/ static boolean canTriggerProject(@NonNull AbstractBuild<?, ?> build,
@NonNull final Job job, @NonNull TaskListener taskListener) {
if (!job.hasPermission(Item.BUILD)) {
String message = String.format("Cannot schedule the build of %s from %s. "
+ "The authenticated build user %s has no Job.BUILD permission",
Expand All @@ -601,7 +601,7 @@ protected QueueTaskFuture schedule(@Nonnull AbstractBuild<?, ?> build, @Nonnull
* @param job Job to be checked
* @return true if the job can be scheduled from the
*/
protected boolean canBeScheduled(@Nonnull Job<?, ?> job) {
protected boolean canBeScheduled(@NonNull Job<?, ?> job) {
if (!job.isBuildable()) {
return false;
}
Expand All @@ -618,7 +618,7 @@ protected QueueTaskFuture schedule(AbstractBuild<?, ?> build, Job project, List<
}

@CheckForNull
protected QueueTaskFuture schedule(@Nonnull AbstractBuild<?, ?> build, @Nonnull Job project, @Nonnull List<Action> list, @Nonnull TaskListener listener) throws InterruptedException, IOException {
protected QueueTaskFuture schedule(@NonNull AbstractBuild<?, ?> build, @NonNull Job project, @NonNull List<Action> list, @NonNull TaskListener listener) throws InterruptedException, IOException {
if (project instanceof ParameterizedJobMixIn.ParameterizedJob) {
return schedule(build, project, ((ParameterizedJobMixIn.ParameterizedJob) project).getQuietPeriod(), list, listener);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import jenkins.model.Jenkins;
import jenkins.security.QueueItemAuthenticator;
import jenkins.security.QueueItemAuthenticatorConfiguration;
Expand Down Expand Up @@ -139,9 +139,9 @@ public void shouldBeUnableToTriggerWithoutPermissions(boolean useBuildStep) thro
Cause.UpstreamCause cause = lastBuild.getCause(Cause.UpstreamCause.class);
assertNotNull("No upstream cause in subproject2", lastBuild);
}
@Nonnull
private FreeStyleProject createProjectWithPermissions(@Nonnull String projectName, @Nonnull String userName,

@NonNull
private FreeStyleProject createProjectWithPermissions(@NonNull String projectName, @NonNull String userName,
@CheckForNull List<Permission> permissions) throws Exception {
final TreeSet<String> userSet = new TreeSet<>(Arrays.asList(userName));

Expand Down