Skip to content

Commit

Permalink
Merge pull request #270 from basil/jsr305
Browse files Browse the repository at this point in the history
EOL usage of JSR 305
  • Loading branch information
basil authored Dec 24, 2020
2 parents d26a492 + f7cd0b3 commit 4740859
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution;
import org.kohsuke.stapler.DataBoundConstructor;

import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.NonNull;
import javax.mail.internet.InternetAddress;
import java.util.HashSet;
import java.util.Iterator;
Expand Down Expand Up @@ -44,7 +44,7 @@ public static class Executor extends SynchronousNonBlockingStepExecution<String>

private final transient EmailExtRecipientStep step;

protected Executor(EmailExtRecipientStep step, @Nonnull StepContext context) {
protected Executor(EmailExtRecipientStep step, @NonNull StepContext context) {
super(context);
this.step = step;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/hudson/plugins/emailext/EmailExtStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.List;
import java.util.Set;

Expand Down Expand Up @@ -185,7 +185,7 @@ public static class EmailExtStepExecution extends SynchronousNonBlockingStepExec

private final transient EmailExtStep step;

protected EmailExtStepExecution(EmailExtStep step, @Nonnull StepContext context) {
protected EmailExtStepExecution(EmailExtStep step, @NonNull StepContext context) {
super(context);
this.step = step;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.StaplerRequest;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import javax.mail.Address;
import javax.mail.Message;
import javax.mail.MessagingException;
Expand Down Expand Up @@ -1120,7 +1120,7 @@ public BuildStepMonitor getRequiredMonitorService() {
* in progress
*/
public static @CheckForNull
Run<?, ?> getPreviousRun(@Nonnull Run<?, ?> run, TaskListener listener) {
Run<?, ?> getPreviousRun(@NonNull Run<?, ?> run, TaskListener listener) {
Run<?, ?> previousRun = run.getPreviousBuild();
if (previousRun != null && previousRun.isBuilding()) {
listener.getLogger().println(Messages.ExtendedEmailPublisher__is_still_in_progress_ignoring_for_purpo(previousRun.getDisplayName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.jenkinsci.plugins.scriptsecurity.scripts.languages.GroovyLanguage;
import org.kohsuke.stapler.DataBoundConstructor;

import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.NonNull;

public class GroovyTemplateConfig extends Config {
@Override
Expand Down Expand Up @@ -50,7 +50,7 @@ public String getDisplayName() {

@NonNull
@Override
public Config newConfig(@Nonnull String id) {
public Config newConfig(@NonNull String id) {
return new GroovyTemplateConfig(id, "Groovy Email Template", "", "");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.jenkinsci.plugins.scriptsecurity.scripts.languages.JellyLanguage;
import org.kohsuke.stapler.DataBoundConstructor;

import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.NonNull;

public class JellyTemplateConfig extends Config {
@Override
Expand Down Expand Up @@ -49,7 +49,7 @@ public String getDisplayName() {

@NonNull
@Override
public Config newConfig(@Nonnull String id) {
public Config newConfig(@NonNull String id) {
return new JellyTemplateConfig(id, "Jelly Email Template", "", "");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.AbstractWhitelist;
import org.jenkinsci.plugins.tokenmacro.TokenMacro;

import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.ArrayList;
Expand All @@ -60,7 +60,7 @@ public EmailExtScriptTokenMacroWhitelist() {
}

@Override
public boolean permitsMethod(@Nonnull Method method, @Nonnull Object receiver, @Nonnull Object[] args) {
public boolean permitsMethod(@NonNull Method method, @NonNull Object receiver, @NonNull Object[] args) {
//method groovy.lang.GroovyObject invokeMethod java.lang.String java.lang.Object (SimpleTemplateScript2 BUILD_ID)
if (method.getDeclaringClass() == GroovyObject.class
&& receiver instanceof EmailExtScript && "invokeMethod".equals(method.getName()) && args.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package hudson.plugins.emailext.groovy.sandbox;

import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.NonNull;
import javax.mail.internet.MimeMessage;
import java.lang.reflect.Method;

Expand All @@ -9,12 +9,12 @@
*/
public class MimeMessageInstanceWhitelist extends ObjectInstanceWhitelist<MimeMessage> {

public MimeMessageInstanceWhitelist(@Nonnull MimeMessage instance) {
public MimeMessageInstanceWhitelist(@NonNull MimeMessage instance) {
super(instance);
}

@Override
public boolean permitsMethod(@Nonnull Method method, @Nonnull Object receiver, @Nonnull Object[] args) {
public boolean permitsMethod(@NonNull Method method, @NonNull Object receiver, @NonNull Object[] args) {
if (permitsInstance(receiver) && isClass(method.getDeclaringClass())) {
String name = method.getName();
return name.startsWith("get") || name.startsWith("set") || name.startsWith("add");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.jenkinsci.plugins.scriptsecurity.sandbox.Whitelist;
import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.AbstractWhitelist;

import javax.annotation.CheckForNull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import java.lang.ref.WeakReference;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package hudson.plugins.emailext.groovy.sandbox;

import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.io.PrintStream;
import java.lang.reflect.Method;

Expand All @@ -14,7 +14,7 @@ public PrintStreamInstanceWhitelist(PrintStream instance) {
}

@Override
public boolean permitsMethod(@Nonnull Method method, @Nonnull Object receiver, @Nonnull Object[] args) {
public boolean permitsMethod(@NonNull Method method, @NonNull Object receiver, @NonNull Object[] args) {
if (permitsInstance(receiver) && isClass(method.getDeclaringClass())) {
String name = method.getName();
return name.equals("write")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package hudson.plugins.emailext.groovy.sandbox;

import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.lang.reflect.Method;
import java.util.Properties;

Expand All @@ -14,7 +14,7 @@ public PropertiesInstanceWhitelist(Properties instance) {
}

@Override
public boolean permitsMethod(@Nonnull Method method, @Nonnull Object receiver, @Nonnull Object[] args) {
public boolean permitsMethod(@NonNull Method method, @NonNull Object receiver, @NonNull Object[] args) {
if (permitsInstance(receiver) && isClass(method.getDeclaringClass())) {
String name = method.getName();
return name.equals("setProperty")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import org.jenkinsci.plugins.scriptsecurity.sandbox.Whitelist;
import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.StaticWhitelist;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
Expand All @@ -15,7 +15,7 @@
public class StaticProxyInstanceWhitelist extends ObjectInstanceWhitelist<Object> {
private Whitelist[] proxies;

public StaticProxyInstanceWhitelist(Object instance, @Nonnull String... resources) throws IOException {
public StaticProxyInstanceWhitelist(Object instance, @NonNull String... resources) throws IOException {
super(instance);
proxies = new Whitelist[resources.length];
for (int i = 0; i < resources.length; i++) {
Expand All @@ -25,7 +25,7 @@ public StaticProxyInstanceWhitelist(Object instance, @Nonnull String... resource
}

@Override
public boolean permitsMethod(@Nonnull Method method, @Nonnull Object receiver, @Nonnull Object[] args) {
public boolean permitsMethod(@NonNull Method method, @NonNull Object receiver, @NonNull Object[] args) {
if (permitsInstance(receiver)) {
for (Whitelist proxy : proxies) {
if (proxy.permitsMethod(method, receiver, args)) {
Expand All @@ -37,7 +37,7 @@ public boolean permitsMethod(@Nonnull Method method, @Nonnull Object receiver, @
}

@Override
public boolean permitsFieldGet(@Nonnull Field field, @Nonnull Object receiver) {
public boolean permitsFieldGet(@NonNull Field field, @NonNull Object receiver) {
if (permitsInstance(receiver)) {
for (Whitelist proxy : proxies) {
if (proxy.permitsFieldGet(field, receiver)) {
Expand All @@ -49,7 +49,7 @@ public boolean permitsFieldGet(@Nonnull Field field, @Nonnull Object receiver) {
}

@Override
public boolean permitsFieldSet(@Nonnull Field field, @Nonnull Object receiver, @CheckForNull Object value) {
public boolean permitsFieldSet(@NonNull Field field, @NonNull Object receiver, @CheckForNull Object value) {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import hudson.model.TaskListener;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

Expand All @@ -17,7 +17,7 @@ public TaskListenerInstanceWhitelist(TaskListener instance) {
}

@Override
public boolean permitsMethod(@Nonnull Method method, @Nonnull Object receiver, @Nonnull Object[] args) {
public boolean permitsMethod(@NonNull Method method, @NonNull Object receiver, @NonNull Object[] args) {
if (permitsInstance(receiver) && isClass(method.getDeclaringClass())) {
String name = method.getName();
return name.equals("getLogger")
Expand All @@ -29,12 +29,12 @@ public boolean permitsMethod(@Nonnull Method method, @Nonnull Object receiver, @
}

@Override
public boolean permitsFieldGet(@Nonnull Field field, @Nonnull Object receiver) {
public boolean permitsFieldGet(@NonNull Field field, @NonNull Object receiver) {
return false;
}

@Override
public boolean permitsFieldSet(@Nonnull Field field, @Nonnull Object receiver, @CheckForNull Object value) {
public boolean permitsFieldSet(@NonNull Field field, @NonNull Object receiver, @CheckForNull Object value) {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import jenkins.model.Jenkins;
import org.apache.commons.lang.StringUtils;

import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.NonNull;
import javax.mail.internet.InternetAddress;
import java.text.MessageFormat;
import java.util.ArrayList;
Expand Down Expand Up @@ -44,7 +44,7 @@ public static List<RecipientProviderDescriptor> allSupporting(Class<? extends Jo
return rt;
}

public static void checkAllSupport(@Nonnull List<? extends RecipientProvider> providers, Class<? extends Job> clazz) {
public static void checkAllSupport(@NonNull List<? extends RecipientProvider> providers, Class<? extends Job> clazz) {
Set<String> notSupported = new TreeSet<>();
for (RecipientProvider provider : providers) {
if (!provider.getDescriptor().isApplicable(clazz)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.jenkinsci.plugins.tokenmacro.MacroEvaluationException;
import org.xml.sax.InputSource;

import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
Expand All @@ -44,7 +44,7 @@ public JellyScriptContent() {
}

@Override
public String evaluate(@Nonnull Run<?, ?> run, FilePath workspace, @Nonnull TaskListener listener, String macroName) throws MacroEvaluationException, IOException, InterruptedException {
public String evaluate(@NonNull Run<?, ?> run, FilePath workspace, @NonNull TaskListener listener, String macroName) throws MacroEvaluationException, IOException, InterruptedException {
InputStream inputStream = null;

try {
Expand All @@ -64,7 +64,7 @@ protected Class<? extends ConfigProvider> getProviderClass() {
return JellyTemplateConfigProvider.class;
}

private String renderContent(@Nonnull Run<?, ?> build, InputStream inputStream, @Nonnull TaskListener listener)
private String renderContent(@NonNull Run<?, ?> build, InputStream inputStream, @NonNull TaskListener listener)
throws JellyException, IOException {
String rawScript = IOUtils.toString(inputStream);
if (inputStream instanceof UserProvidedContentInputStream) {
Expand Down Expand Up @@ -93,7 +93,7 @@ private String convert(Run<?, ?> build, JellyContext context, Script script)
return output.toString(getCharset(build));
}

private JellyContext createContext(Object it, @Nonnull Run<?, ?> build, @Nonnull TaskListener listener) {
private JellyContext createContext(Object it, @NonNull Run<?, ?> build, @NonNull TaskListener listener) {
JellyContext context = new JellyContext();
ExtendedEmailPublisherDescriptor descriptor = Jenkins.get().getDescriptorByType(ExtendedEmailPublisherDescriptor.class);
context.setVariable("it", it);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import org.acegisecurity.Authentication;
import org.acegisecurity.userdetails.UsernameNotFoundException;

import javax.annotation.CheckForNull;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import javax.mail.internet.InternetAddress;
import java.io.IOException;
import java.lang.reflect.Field;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.StaplerRequest;

import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.io.IOException;
import java.io.ObjectStreamException;
import java.io.PrintStream;
Expand Down Expand Up @@ -76,7 +76,7 @@ private boolean hasScript() {
}

@Override
public boolean configure(@Nonnull StaplerRequest req, @Nonnull JSONObject formData) {
public boolean configure(@NonNull StaplerRequest req, @NonNull JSONObject formData) {
super.configure(req, formData);
if(formData.containsKey("secureTriggerScript")) {
this.secureTriggerScript = req.bindJSON(SecureGroovyScript.class, formData.getJSONObject("secureTriggerScript"));
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/hudson/plugins/emailext/EmailExtStepTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.jvnet.mock_javamail.Mailbox;
import org.kohsuke.stapler.DataBoundConstructor;

import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.NonNull;
import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.internet.MimeMessage;
Expand Down Expand Up @@ -174,7 +174,7 @@ public static class Execution extends SynchronousNonBlockingStepExecution<Boolea

private final transient FileCopyStep step;

protected Execution(FileCopyStep step, @Nonnull StepContext context) {
protected Execution(FileCopyStep step, @NonNull StepContext context) {
super(context);
this.step = step;
}
Expand Down

0 comments on commit 4740859

Please sign in to comment.