Skip to content

Commit 2fe6f81

Browse files
committed
Replace JSR-305 annotations with spotbugs annotations
Annotations for Nonnull, CheckForNull, and several others were proposed for Java as part of dormant Java specification request JSR-305. The proposal never became a part of standard Java. Jenkins plugins should switch from using JSR-305 annotations to use Spotbugs annotations that provide the same semantics. The [mailing list discussion](https://groups.google.com/g/jenkinsci-dev/c/uE1wwtVi1W0/m/gLxdEJmlBQAJ) from James Nord describes the affected annotations and why they should be replaced with annotations that are actively maintained. The ["Improve a plugin" tutorial](https://www.jenkins.io/doc/developer/tutorial-improve/replace-jsr-305-annotations/) provides instructions to perform this change. An [OpenRewrite recipe](https://docs.openrewrite.org/recipes/jenkins/javaxannotationstospotbugs) is also available and is even better than the tutorial. Spotbugs annotations were already imported in the source file that was still using a JSR-305 annotation. Confirmed that automated tests pass on Linux with Java 21.
1 parent 6d24a57 commit 2fe6f81

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/main/java/com/cloudbees/jenkins/plugins/BitBucketPayload.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import hudson.model.InvisibleAction;
77
import hudson.model.Run;
88

9-
import javax.annotation.Nonnull;
109
import java.util.logging.Level;
1110
import java.util.logging.Logger;
1211

@@ -16,13 +15,13 @@
1615
* @version 1.1.5
1716
*/
1817
public class BitBucketPayload extends InvisibleAction implements EnvironmentContributingAction {
19-
private final @Nonnull String payload;
18+
private final @NonNull String payload;
2019

21-
public BitBucketPayload(@Nonnull String payload) {
20+
public BitBucketPayload(@NonNull String payload) {
2221
this.payload = payload;
2322
}
2423

25-
@Nonnull
24+
@NonNull
2625
public String getPayload() {
2726
return payload;
2827
}

0 commit comments

Comments
 (0)