Skip to content

Commit a9780ab

Browse files
committed
mark @nullable
Signed-off-by: neo <1100909+neowu@users.noreply.github.com>
1 parent bde07a8 commit a9780ab

File tree

9 files changed

+37
-4
lines changed

9 files changed

+37
-4
lines changed

core-ng/src/main/java/core/framework/internal/web/HTTPErrorHandler.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import io.undertow.server.HttpServerExchange;
2020
import io.undertow.util.HeaderMap;
2121
import io.undertow.util.Headers;
22+
import org.jspecify.annotations.Nullable;
2223
import org.slf4j.Logger;
2324
import org.slf4j.LoggerFactory;
2425

@@ -30,6 +31,7 @@
3031
public class HTTPErrorHandler {
3132
private final Logger logger = LoggerFactory.getLogger(HTTPErrorHandler.class);
3233
private final ResponseHandler responseHandler;
34+
@Nullable
3335
public ErrorHandler customErrorHandler;
3436

3537
HTTPErrorHandler(ResponseHandler responseHandler) {

core-ng/src/main/java/core/framework/internal/web/HTTPHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import io.undertow.util.HeaderMap;
2121
import io.undertow.util.Headers;
2222
import io.undertow.util.HttpString;
23+
import org.jspecify.annotations.Nullable;
2324
import org.slf4j.Logger;
2425
import org.slf4j.LoggerFactory;
2526

@@ -144,7 +145,7 @@ void linkContext(ActionLog actionLog, HeaderMap headers) {
144145
actionLog.warningContext.maxProcessTimeInNano(maxProcessTime(headers.getFirst(HEADER_TIMEOUT)));
145146
}
146147

147-
long maxProcessTime(String timeout) {
148+
long maxProcessTime(@Nullable String timeout) {
148149
if (timeout != null) {
149150
try {
150151
return Long.parseLong(timeout);

core-ng/src/main/java/core/framework/internal/web/HTTPIOHandler.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import io.undertow.util.HeaderMap;
1212
import io.undertow.util.HttpString;
1313
import io.undertow.util.Methods;
14+
import org.jspecify.annotations.Nullable;
1415
import org.slf4j.Logger;
1516
import org.slf4j.LoggerFactory;
1617
import org.xnio.channels.StreamSourceChannel;
@@ -25,13 +26,14 @@ public class HTTPIOHandler implements HttpHandler {
2526
private final Logger logger = LoggerFactory.getLogger(HTTPIOHandler.class);
2627

2728
private final HTTPHandler httpHandler;
29+
@Nullable
2830
private final ServerSentEventHandler sseHandler;
2931
private final ShutdownHandler shutdownHandler;
3032

3133
private final FormParserFactory formParserFactory;
3234
private final long maxEntitySize;
3335

34-
HTTPIOHandler(HTTPHandler httpHandler, ShutdownHandler shutdownHandler, long maxEntitySize, ServerSentEventHandler sseHandler) {
36+
HTTPIOHandler(HTTPHandler httpHandler, ShutdownHandler shutdownHandler, long maxEntitySize, @Nullable ServerSentEventHandler sseHandler) {
3537
this.httpHandler = httpHandler;
3638
this.shutdownHandler = shutdownHandler;
3739
formParserFactory = createFormParserFactory();

core-ng/src/main/java/core/framework/internal/web/HTTPServer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import io.undertow.server.handlers.encoding.ContentEncodingRepository;
1313
import io.undertow.server.handlers.encoding.EncodingHandler;
1414
import io.undertow.server.handlers.encoding.GzipEncodingProvider;
15+
import org.jspecify.annotations.Nullable;
1516
import org.slf4j.Logger;
1617
import org.slf4j.LoggerFactory;
1718
import org.xnio.Options;
@@ -40,7 +41,9 @@ public class HTTPServer {
4041
private final Logger logger = LoggerFactory.getLogger(HTTPServer.class);
4142
private final ExecutorService worker = ThreadPools.virtualThreadExecutor("http-handler-");
4243

44+
@Nullable
4345
public ServerSentEventHandler sseHandler;
46+
@Nullable
4447
private Undertow server;
4548

4649
public HTTPServer(LogManager logManager) {

core-ng/src/main/java/core/framework/internal/web/HTTPServerConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import core.framework.util.Lists;
44
import core.framework.web.Interceptor;
5+
import org.jspecify.annotations.Nullable;
56

67
import java.util.List;
78

@@ -10,11 +11,14 @@
1011
*/
1112
public class HTTPServerConfig {
1213
public final List<Interceptor> interceptors = Lists.newArrayList();
14+
@Nullable
1315
public HTTPHost httpHost;
16+
@Nullable
1417
public HTTPHost httpsHost;
1518
public boolean gzip;
1619
public long maxEntitySize = 10_000_000; // limit max post body to 10M, apply to multipart as well
1720

21+
@Nullable
1822
public HTTPHost httpsHost() {
1923
if (httpHost == null && httpsHost == null) return new HTTPHost("0.0.0.0", 8443); // by default start https only
2024
return httpsHost;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@NullMarked
2+
package core.framework.internal.web;
3+
4+
import org.jspecify.annotations.NullMarked;

core-ng/src/main/java/core/framework/internal/web/route/Path.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package core.framework.internal.web.route;
22

3+
import org.jspecify.annotations.Nullable;
4+
35
/**
46
* @author neo
57
*/
@@ -28,6 +30,7 @@ public static Path parse(String path) {
2830
}
2931

3032
public final String value;
33+
@Nullable
3134
public Path next;
3235

3336
private Path(String value) {

core-ng/src/main/java/core/framework/internal/web/route/PathNode.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import core.framework.internal.web.request.PathParams;
44
import core.framework.util.Strings;
5+
import org.jspecify.annotations.Nullable;
56

67
import java.util.HashMap;
78
import java.util.Map;
@@ -12,21 +13,26 @@
1213
* @author neo
1314
*/
1415
class PathNode {
16+
@Nullable
1517
private final String param;
18+
@Nullable
1619
private URLHandler handler;
20+
@Nullable
1721
private Map<String, PathNode> staticNodes;
22+
@Nullable
1823
private PathNode dynamicNode;
24+
@Nullable
1925
private PathNode wildcardNode;
2026

21-
PathNode(String param) {
27+
PathNode(@Nullable String param) {
2228
this.param = param;
2329
}
2430

2531
URLHandler register(String pathPattern) {
2632
return register(pathPattern, Path.parse(pathPattern).next);
2733
}
2834

29-
private URLHandler register(String pathPattern, Path currentPath) {
35+
private URLHandler register(String pathPattern, @Nullable Path currentPath) {
3036
if (currentPath == null) {
3137
if (handler == null) handler = new URLHandler(pathPattern);
3238
return handler;
@@ -68,10 +74,12 @@ private URLHandler registerDynamicNode(String pathPattern, Path currentPath, Str
6874
return dynamicNode.register(pathPattern, currentPath.next);
6975
}
7076

77+
@Nullable
7178
URLHandler find(String path, PathParams pathParams) {
7279
return find(Path.parse(path), pathParams);
7380
}
7481

82+
@Nullable
7583
private URLHandler find(Path currentPath, PathParams pathParams) {
7684
Path nextPath = currentPath.next;
7785
if (nextPath == null) return handler;
@@ -92,6 +100,7 @@ private URLHandler find(Path currentPath, PathParams pathParams) {
92100
return null;
93101
}
94102

103+
@Nullable
95104
private URLHandler findStatic(Path nextPath, PathParams pathParams) {
96105
if (staticNodes != null) {
97106
PathNode nextNode = staticNodes.get(nextPath.value);
@@ -102,6 +111,7 @@ private URLHandler findStatic(Path nextPath, PathParams pathParams) {
102111
return null;
103112
}
104113

114+
@Nullable
105115
private URLHandler findDynamic(Path nextPath, PathParams pathParams) {
106116
if (dynamicNode != null) {
107117
URLHandler handler = dynamicNode.find(nextPath, pathParams);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@NullMarked
2+
package core.framework.internal.web.route;
3+
4+
import org.jspecify.annotations.NullMarked;

0 commit comments

Comments
 (0)