Skip to content

Commit 9b419f7

Browse files
committed
fix: resolve nullability issues identified by NullAway
1 parent 48d35b5 commit 9b419f7

File tree

6 files changed

+15
-6
lines changed

6 files changed

+15
-6
lines changed

src/main/java/org/juv25d/FilterRegistration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package org.juv25d;
22

3+
import org.jspecify.annotations.Nullable;
34
import org.juv25d.filter.Filter;
45

5-
public record FilterRegistration(Filter filter, int order, String pattern)
6+
public record FilterRegistration(Filter filter, int order, @Nullable String pattern)
67
implements Comparable<FilterRegistration> {
78

89
@Override

src/main/java/org/juv25d/Pipeline.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.juv25d.filter.FilterChainImpl;
55
import org.juv25d.http.HttpRequest;
66
import org.juv25d.router.Router; // New import
7+
import org.juv25d.router.SimpleRouter;
78

89
import java.util.ArrayList;
910
import java.util.Collections;
@@ -18,7 +19,7 @@ public class Pipeline {
1819
private final List<FilterRegistration> globalFilters = new CopyOnWriteArrayList<>();
1920
private final Map<String, List<FilterRegistration>> routeFilters = new ConcurrentHashMap<>();
2021
private volatile List<Filter> sortedGlobalFilters = List.of();
21-
private volatile Router router; // Changed from Plugin plugin;
22+
private volatile Router router = new SimpleRouter(); // Changed from Plugin plugin;
2223

2324
public void addGlobalFilter(Filter filter, int order) {
2425
globalFilters.add(new FilterRegistration(filter, order, null));

src/main/java/org/juv25d/http/HttpParser.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.io.InputStream;
55
import java.util.Map;
66
import java.util.TreeMap;
7+
import org.jspecify.annotations.Nullable;
78

89
public class HttpParser {
910

@@ -63,6 +64,7 @@ public HttpRequest parse(InputStream in) throws IOException {
6364
return new HttpRequest(method, path, query, version, headers, body, "UNKNOWN");
6465
}
6566

67+
@Nullable
6668
private String readLine(InputStream in) throws IOException {
6769
StringBuilder sb = new StringBuilder();
6870
int b;

src/main/java/org/juv25d/http/HttpRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package org.juv25d.http;
22

33
import java.util.Map;
4+
import org.jspecify.annotations.Nullable;
45

56
public record HttpRequest(
67
String method,
78
String path,
8-
String queryString,
9+
@Nullable String queryString,
910
String httpVersion,
1011
Map<String, String> headers,
1112
byte[] body,

src/main/java/org/juv25d/http/HttpResponse.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public class HttpResponse {
1515
private byte[] body;
1616

1717
public HttpResponse(){
18+
this.statusCode = 200;
19+
this.statusText = "OK";
1820
this.headers = new LinkedHashMap<>();
1921
this.body = new byte[0];
2022
}

src/main/java/org/juv25d/util/ConfigLoader.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
package org.juv25d.util;
22

3+
import org.jspecify.annotations.Nullable;
34
import org.yaml.snakeyaml.Yaml;
45

56
import java.io.InputStream;
67
import java.util.Map;
78

89
public class ConfigLoader {
10+
@Nullable
911
private static ConfigLoader instance;
1012
private int port;
11-
private String logLevel;
12-
private String rootDirectory;
13+
private String logLevel = "INFO";
14+
private String rootDirectory = "static";
1315
private long requestsPerMinute;
1416
private long burstCapacity;
1517
private boolean rateLimitingEnabled;
@@ -45,7 +47,7 @@ private void loadConfiguration() {
4547
// logging
4648
Map<String, Object> loggingConfig = (Map<String, Object>) config.get("logging");
4749
if (loggingConfig != null) {
48-
this.logLevel = (String) loggingConfig.get("level");
50+
this.logLevel = (String) loggingConfig.getOrDefault("level", "INFO");
4951
}
5052

5153
// rate-limiting

0 commit comments

Comments
 (0)