From 98754f5ac7c40b9b134b9fde46603d16ac41df76 Mon Sep 17 00:00:00 2001 From: Maciej Kucharczyk Date: Wed, 22 Oct 2025 20:01:07 +0200 Subject: [PATCH] [java] JSpecify annotations for `CommandCodec` --- java/src/org/openqa/selenium/remote/CommandCodec.java | 2 ++ .../selenium/remote/codec/AbstractHttpCommandCodec.java | 5 ++++- .../selenium/remote/codec/w3c/W3CHttpCommandCodec.java | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/java/src/org/openqa/selenium/remote/CommandCodec.java b/java/src/org/openqa/selenium/remote/CommandCodec.java index afc5eedd9bc62..ded0284c2543b 100644 --- a/java/src/org/openqa/selenium/remote/CommandCodec.java +++ b/java/src/org/openqa/selenium/remote/CommandCodec.java @@ -17,6 +17,7 @@ package org.openqa.selenium.remote; +import org.jspecify.annotations.NullMarked; import org.openqa.selenium.UnsupportedCommandException; import org.openqa.selenium.remote.http.HttpMethod; @@ -25,6 +26,7 @@ * * @param The type of encoded command. */ +@NullMarked public interface CommandCodec { /** diff --git a/java/src/org/openqa/selenium/remote/codec/AbstractHttpCommandCodec.java b/java/src/org/openqa/selenium/remote/codec/AbstractHttpCommandCodec.java index 412d742fa079c..385c0f68d5e21 100644 --- a/java/src/org/openqa/selenium/remote/codec/AbstractHttpCommandCodec.java +++ b/java/src/org/openqa/selenium/remote/codec/AbstractHttpCommandCodec.java @@ -90,6 +90,8 @@ import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import org.openqa.selenium.UnsupportedCommandException; import org.openqa.selenium.internal.Require; import org.openqa.selenium.json.Json; @@ -106,6 +108,7 @@ * * @see W3C WebDriver spec */ +@NullMarked public abstract class AbstractHttpCommandCodec implements CommandCodec { private static final String SESSION_ID_PARAM = "sessionId"; @@ -362,7 +365,7 @@ private CommandSpec(HttpMethod method, String path) { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (o instanceof CommandSpec) { CommandSpec that = (CommandSpec) o; return this.method.equals(that.method) && this.path.equals(that.path); diff --git a/java/src/org/openqa/selenium/remote/codec/w3c/W3CHttpCommandCodec.java b/java/src/org/openqa/selenium/remote/codec/w3c/W3CHttpCommandCodec.java index e775978984bcb..8dad8d74b6d71 100644 --- a/java/src/org/openqa/selenium/remote/codec/w3c/W3CHttpCommandCodec.java +++ b/java/src/org/openqa/selenium/remote/codec/w3c/W3CHttpCommandCodec.java @@ -86,6 +86,7 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.jspecify.annotations.NullMarked; import org.openqa.selenium.InvalidSelectorException; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.remote.WebElementToJsonConverter; @@ -96,6 +97,7 @@ * * @see W3C WebDriver spec */ +@NullMarked public class W3CHttpCommandCodec extends AbstractHttpCommandCodec { private static final ConcurrentHashMap ATOM_SCRIPTS = new ConcurrentHashMap<>();