Skip to content

Commit 549b83b

Browse files
Annotate Java CopilotRequestContext.sessionId() as @nullable
sessionId() returns null when the request was issued outside any session, but the nullability was only documented in the Javadoc. Every other SDK makes this explicit in the type system (TypeScript string?, Python str | None, .NET string?, Rust Option<String>). Add @nullable from the already-declared spotbugs-annotations dependency on the field, constructor parameter, and getter so SpotBugs and IDEs surface null-safety warnings, aligning Java with the other SDKs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent d05e86c commit 549b83b

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

java/src/main/java/com/github/copilot/CopilotRequestContext.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import java.util.Map;
99
import java.util.concurrent.CompletableFuture;
1010

11+
import edu.umd.cs.findbugs.annotations.Nullable;
12+
1113
/**
1214
* The per-request context handed to every {@link CopilotRequestHandler} hook.
1315
* It exposes the routing and cancellation details of a single intercepted
@@ -18,6 +20,7 @@
1820
public final class CopilotRequestContext {
1921

2022
private final String requestId;
23+
@Nullable
2124
private final String sessionId;
2225
private final CopilotRequestTransport transport;
2326
private final String url;
@@ -26,7 +29,7 @@ public final class CopilotRequestContext {
2629

2730
private LlmWebSocketResponseBridge webSocketResponse;
2831

29-
CopilotRequestContext(String requestId, String sessionId, CopilotRequestTransport transport, String url,
32+
CopilotRequestContext(String requestId, @Nullable String sessionId, CopilotRequestTransport transport, String url,
3033
Map<String, List<String>> headers, CompletableFuture<Void> cancellation) {
3134
this.requestId = requestId;
3235
this.sessionId = sessionId;
@@ -53,6 +56,7 @@ public String requestId() {
5356
*
5457
* @return the session id, or {@code null}
5558
*/
59+
@Nullable
5660
public String sessionId() {
5761
return sessionId;
5862
}

0 commit comments

Comments
 (0)