Skip to content

Commit d8b0bed

Browse files
authored
Merge pull request #3907 from jooby-project/3906
refactor: migrate nullability annotations from SpotBugs to JSpecify
2 parents 10a2417 + 5ef21f7 commit d8b0bed

488 files changed

Lines changed: 3037 additions & 3425 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/src/main/java/io/jooby/adoc/DocPostprocessor.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import java.util.Set;
99
import java.util.UUID;
1010

11-
import edu.umd.cs.findbugs.annotations.NonNull;
1211
import org.asciidoctor.extension.Postprocessor;
1312
import org.jcodings.util.Hash;
1413
import org.jsoup.Jsoup;
@@ -145,7 +144,6 @@ private static void headerIds(Document doc, int level) {
145144
});
146145
}
147146

148-
@NonNull
149147
private static String cleanId(String id) {
150148
return id.replaceAll("-\\d+$", "");
151149
}

jooby/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
<dependencies>
1515

1616
<dependency>
17-
<groupId>com.github.spotbugs</groupId>
18-
<artifactId>spotbugs-annotations</artifactId>
17+
<groupId>org.jspecify</groupId>
18+
<artifactId>jspecify</artifactId>
1919
</dependency>
2020

2121
<!-- Logging System -->

jooby/src/main/java/io/jooby/AttachedFile.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
import java.io.InputStream;
1010
import java.nio.file.Path;
1111

12-
import edu.umd.cs.findbugs.annotations.NonNull;
13-
1412
/**
1513
* Represents a file attachment response.
1614
*
@@ -26,7 +24,7 @@ public class AttachedFile extends FileDownload {
2624
* @param fileName Filename.
2725
* @param fileSize File size or <code>-1</code> if unknown.
2826
*/
29-
public AttachedFile(@NonNull InputStream content, @NonNull String fileName, long fileSize) {
27+
public AttachedFile(InputStream content, String fileName, long fileSize) {
3028
super(Mode.ATTACHMENT, content, fileName, fileSize);
3129
}
3230

@@ -36,7 +34,7 @@ public AttachedFile(@NonNull InputStream content, @NonNull String fileName, long
3634
* @param content File content.
3735
* @param fileName Filename.
3836
*/
39-
public AttachedFile(@NonNull InputStream content, @NonNull String fileName) {
37+
public AttachedFile(InputStream content, String fileName) {
4038
super(Mode.ATTACHMENT, content, fileName);
4139
}
4240

@@ -47,7 +45,7 @@ public AttachedFile(@NonNull InputStream content, @NonNull String fileName) {
4745
* @param fileName Filename.
4846
* @throws IOException For IO exception while reading file.
4947
*/
50-
public AttachedFile(@NonNull Path file, @NonNull String fileName) throws IOException {
48+
public AttachedFile(Path file, String fileName) throws IOException {
5149
super(Mode.ATTACHMENT, file, fileName);
5250
}
5351

@@ -57,7 +55,7 @@ public AttachedFile(@NonNull Path file, @NonNull String fileName) throws IOExcep
5755
* @param file File content.
5856
* @throws IOException For IO exception while reading file.
5957
*/
60-
public AttachedFile(@NonNull Path file) throws IOException {
58+
public AttachedFile(Path file) throws IOException {
6159
super(Mode.ATTACHMENT, file);
6260
}
6361
}

jooby/src/main/java/io/jooby/Body.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
import java.util.List;
1515
import java.util.Set;
1616

17-
import edu.umd.cs.findbugs.annotations.NonNull;
18-
import edu.umd.cs.findbugs.annotations.Nullable;
17+
import org.jspecify.annotations.Nullable;
18+
1919
import io.jooby.exception.MissingValueException;
2020
import io.jooby.internal.ByteArrayBody;
2121
import io.jooby.internal.FileBody;
@@ -39,7 +39,7 @@ public interface Body extends Value {
3939
* @param charset Charset.
4040
* @return Body as string.
4141
*/
42-
default String value(@NonNull Charset charset) {
42+
default String value(Charset charset) {
4343
byte[] bytes = bytes();
4444
if (bytes.length == 0) {
4545
throw new MissingValueException("body");
@@ -99,7 +99,7 @@ default Iterator<Value> iterator() {
9999
InputStream stream();
100100

101101
@Override
102-
default <T> List<T> toList(@NonNull Class<T> type) {
102+
default <T> List<T> toList(Class<T> type) {
103103
return to(Reified.list(type).getType());
104104
}
105105

@@ -112,11 +112,11 @@ default <T> List<T> toList(@NonNull Class<T> type) {
112112
}
113113

114114
@Override
115-
default <T> T to(@NonNull Class<T> type) {
115+
default <T> T to(Class<T> type) {
116116
return to((Type) type);
117117
}
118118

119-
default @Nullable @Override <T> T toNullable(@NonNull Class<T> type) {
119+
default @Nullable @Override <T> T toNullable(Class<T> type) {
120120
return toNullable((Type) type);
121121
}
122122

@@ -127,7 +127,7 @@ default <T> T to(@NonNull Class<T> type) {
127127
* @param <T> Generic type.
128128
* @return Converted value.
129129
*/
130-
<T> T to(@NonNull Type type);
130+
<T> T to(Type type);
131131

132132
/**
133133
* Convert this body into the given type.
@@ -136,7 +136,7 @@ default <T> T to(@NonNull Class<T> type) {
136136
* @param <T> Generic type.
137137
* @return Converted value or <code>null</code>.
138138
*/
139-
@Nullable <T> T toNullable(@NonNull Type type);
139+
@Nullable <T> T toNullable(Type type);
140140

141141
/* **********************************************************************************************
142142
* Factory methods:
@@ -149,7 +149,7 @@ default <T> T to(@NonNull Class<T> type) {
149149
* @param ctx Current context.
150150
* @return Empty body.
151151
*/
152-
static Body empty(@NonNull Context ctx) {
152+
static Body empty(Context ctx) {
153153
return ByteArrayBody.empty(ctx);
154154
}
155155

@@ -161,7 +161,7 @@ static Body empty(@NonNull Context ctx) {
161161
* @param size Size in bytes or <code>-1</code>.
162162
* @return A new body.
163163
*/
164-
static Body of(@NonNull Context ctx, @NonNull InputStream stream, long size) {
164+
static Body of(Context ctx, InputStream stream, long size) {
165165
return new InputStreamBody(ctx, stream, size);
166166
}
167167

@@ -172,7 +172,7 @@ static Body of(@NonNull Context ctx, @NonNull InputStream stream, long size) {
172172
* @param bytes byte array.
173173
* @return A new body.
174174
*/
175-
static Body of(@NonNull Context ctx, @NonNull byte[] bytes) {
175+
static Body of(Context ctx, byte[] bytes) {
176176
return new ByteArrayBody(ctx, bytes);
177177
}
178178

@@ -183,7 +183,7 @@ static Body of(@NonNull Context ctx, @NonNull byte[] bytes) {
183183
* @param file File.
184184
* @return A new body.
185185
*/
186-
static Body of(@NonNull Context ctx, @NonNull Path file) {
186+
static Body of(Context ctx, Path file) {
187187
return new FileBody(ctx, file);
188188
}
189189
}

jooby/src/main/java/io/jooby/ByteRange.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import java.io.IOException;
99
import java.io.InputStream;
1010

11-
import edu.umd.cs.findbugs.annotations.NonNull;
12-
import edu.umd.cs.findbugs.annotations.Nullable;
11+
import org.jspecify.annotations.Nullable;
12+
1313
import io.jooby.internal.NoByteRange;
1414
import io.jooby.internal.NotSatisfiableByteRange;
1515
import io.jooby.internal.SingleByteRange;
@@ -44,7 +44,7 @@ public interface ByteRange {
4444
* @param contentLength Content length.
4545
* @return Byte range instance.
4646
*/
47-
static @NonNull ByteRange parse(@Nullable String value, long contentLength) {
47+
static ByteRange parse(@Nullable String value, long contentLength) {
4848
if (contentLength <= 0 || value == null) {
4949
// NOOP
5050
return new NoByteRange(contentLength);
@@ -129,7 +129,7 @@ public interface ByteRange {
129129
*
130130
* @return Value for <code>Content-Range</code> response header.
131131
*/
132-
@NonNull String getContentRange();
132+
String getContentRange();
133133

134134
/**
135135
* For partial requests this method returns {@link StatusCode#PARTIAL_CONTENT}.
@@ -141,7 +141,7 @@ public interface ByteRange {
141141
*
142142
* @return Status code.
143143
*/
144-
@NonNull StatusCode getStatusCode();
144+
StatusCode getStatusCode();
145145

146146
/**
147147
* For partial request this method set the following byte range response headers:
@@ -157,7 +157,7 @@ public interface ByteRange {
157157
* @param ctx Web context.
158158
* @return This byte range request.
159159
*/
160-
@NonNull ByteRange apply(@NonNull Context ctx);
160+
ByteRange apply(Context ctx);
161161

162162
/**
163163
* For partial requests this method generates a new truncated input stream.
@@ -170,5 +170,5 @@ public interface ByteRange {
170170
* @return A truncated input stream for partial request or same input stream.
171171
* @throws IOException When truncation fails.
172172
*/
173-
@NonNull InputStream apply(@NonNull InputStream input) throws IOException;
173+
InputStream apply(InputStream input) throws IOException;
174174
}

jooby/src/main/java/io/jooby/CompletionListeners.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
import java.util.List;
1010
import java.util.stream.Stream;
1111

12-
import edu.umd.cs.findbugs.annotations.NonNull;
13-
1412
/**
1513
* Utility class that group one or more completion listeners and execute them in reverse order.
1614
*
@@ -28,7 +26,7 @@ public CompletionListeners() {}
2826
*
2927
* @param listener Listener.
3028
*/
31-
public void addListener(@NonNull Route.Complete listener) {
29+
public void addListener(Route.Complete listener) {
3230
if (listeners == null) {
3331
listeners = new ArrayList<>();
3432
}
@@ -40,7 +38,7 @@ public void addListener(@NonNull Route.Complete listener) {
4038
*
4139
* @param ctx Listeners.
4240
*/
43-
public void run(@NonNull Context ctx) {
41+
public void run(Context ctx) {
4442
if (listeners != null) {
4543
Throwable cause = null;
4644
for (int i = listeners.size() - 1; i >= 0; i--) {

0 commit comments

Comments
 (0)