Skip to content

[java] specify nullability in org.openqa.selenium.grid.* packages#17173

Merged
asolntsev merged 2 commits intoSeleniumHQ:trunkfrom
asolntsev:nullability-in-grid
Mar 5, 2026
Merged

[java] specify nullability in org.openqa.selenium.grid.* packages#17173
asolntsev merged 2 commits intoSeleniumHQ:trunkfrom
asolntsev:nullability-in-grid

Conversation

@asolntsev
Copy link
Contributor

🔗 Related Issues

Partially implements #14291

💥 What does this PR do?

Adds JSpecify nullability annotations to packages

  • org.openqa.selenium.grid.*

There are few warnings that can be improved later. Especially in grid tests.

🔄 Types of changes

  • Cleanup (formatting, renaming)

@asolntsev asolntsev added this to the 4.42.0 milestone Mar 4, 2026
@asolntsev asolntsev self-assigned this Mar 4, 2026
@selenium-ci selenium-ci added B-grid Everything grid and server related C-java Java Bindings B-build Includes scripting, bazel and CI integrations labels Mar 4, 2026
@asolntsev asolntsev added I-enhancement Something could be better and removed B-build Includes scripting, bazel and CI integrations labels Mar 4, 2026
@qodo-code-review
Copy link
Contributor

Review Summary by Qodo

Add JSpecify nullability annotations to Grid and related packages

✨ Enhancement 🧪 Tests

Grey Divider

Walkthroughs

Description
  Adds JSpecify nullability annotations across the Selenium Grid and related packages to improve type
  safety and null-safety analysis.
  **Key changes:**
• Added @NullMarked package-level annotations to multiple grid packages
  (org.openqa.selenium.grid.*, org.openqa.selenium.manager, org.openqa.selenium.cli)
• Added @Nullable and @NonNull annotations to fields, method parameters, and return types
  throughout grid components including:
  - Kubernetes session factory and options
  - Docker session factory and options
  - Relay session factory and options
  - Session data classes (SessionClosedData, SessionEventData, SessionCreatedData, etc.)
  - Grid distributor and node registry implementations
  - Configuration and session management classes
• Removed unnecessary null checks where types are guaranteed non-null
• Replaced deprecated Contents.string() calls with response::contentAsString method references
• Improved code quality by extracting helper methods and using stream APIs
• Refactored test classes to use local variables instead of class-level fields for better isolation
• Made fromJson methods private where appropriate and added @SuppressWarnings annotations for
  data flow issues
• Introduced self() helper method in AbstractDriverOptions to improve type safety of self-type
  casting
• Converted static logger field to local variable in Debug class

Grey Divider

File Changes

1. java/src/org/openqa/selenium/grid/node/kubernetes/KubernetesSessionFactory.java ✨ Enhancement +33/-25

Add JSpecify nullability annotations to Kubernetes session factory

• Added @Nullable annotations to fields and method parameters for nullable types
 (imagePullPolicy, serviceAccount, videoImage, assetsPath, jobTemplate,
 nodePodOwnerReference)
• Removed unnecessary null checks before calling methods on non-null values (e.g.,
 browserName.isEmpty() instead of browserName == null || browserName.isEmpty())
• Replaced Contents.string(response) with response::contentAsString method reference
• Added @Nullable return type annotations to methods that can return null

java/src/org/openqa/selenium/grid/node/kubernetes/KubernetesSessionFactory.java


2. java/test/org/openqa/selenium/grid/node/config/SessionCapabilitiesMutatorTest.java 🧪 Tests +28/-26

Refactor test to use local variables instead of fields

• Converted class-level fields to local variables within test methods for better test isolation
• Removed unnecessary field declarations (sessionCapabilitiesMutator, stereotype,
 capabilities)
• Improved test method readability by declaring variables at point of use

java/test/org/openqa/selenium/grid/node/config/SessionCapabilitiesMutatorTest.java


3. java/src/org/openqa/selenium/grid/node/kubernetes/InheritedPodSpec.java ✨ Enhancement +53/-42

Add JSpecify nullability annotations to inherited pod spec

• Added @Nullable annotations to constructor parameters and fields for optional Kubernetes pod
 configuration properties
• Added @Nullable return type annotations to getter methods that can return null values
• Marked fields like affinity, dnsPolicy, dnsConfig, securityContext, priorityClassName,
 serviceAccountName, imagePullPolicy, assetsClaimName, nodePodName, and nodePodUid as
 nullable

java/src/org/openqa/selenium/grid/node/kubernetes/InheritedPodSpec.java


View more (171)
4. java/src/org/openqa/selenium/grid/data/SessionClosedData.java ✨ Enhancement +16/-9

Add JSpecify nullability annotations to session closed data

• Added @Nullable annotations to fields and constructor parameters (nodeId, nodeUri,
 capabilities, startTime)
• Added @Nullable return type annotations to getter methods
• Added @SuppressWarnings annotation to fromJson method for data flow issues
• Simplified null check in getSessionDuration() method

java/src/org/openqa/selenium/grid/data/SessionClosedData.java


5. java/src/org/openqa/selenium/grid/node/docker/DockerSessionFactory.java ✨ Enhancement +11/-7

Add JSpecify nullability annotations to Docker session factory

• Added @Nullable annotations to fields and method parameters (videoImage, assetsPath)
• Removed unnecessary null check before calling browserName.isEmpty()
• Replaced Contents.string(response) with response::contentAsString method reference
• Added @Nullable return type annotations to methods that can return null

java/src/org/openqa/selenium/grid/node/docker/DockerSessionFactory.java


6. java/src/org/openqa/selenium/remote/AbstractDriverOptions.java ✨ Enhancement +19/-10

Add JSpecify annotations and refactor self-type casting

• Added @NonNull and @Nullable JSpecify annotations to method signatures
• Introduced self() helper method to replace repeated unsafe casts (DO) this
• Improved type safety by centralizing the cast operation with proper annotations

java/src/org/openqa/selenium/remote/AbstractDriverOptions.java


7. java/src/org/openqa/selenium/grid/node/kubernetes/KubernetesOptions.java ✨ Enhancement +12/-5

Add JSpecify nullability annotations to Kubernetes options

• Added @Nullable annotations to method parameters and return types (kubeClient, assetsPath,
 map, prefix, resourceString, mapString)
• Marked methods that can return null with @Nullable annotation

java/src/org/openqa/selenium/grid/node/kubernetes/KubernetesOptions.java


8. java/src/org/openqa/selenium/grid/data/SessionEventData.java ✨ Enhancement +10/-6

Add JSpecify nullability annotations to session event data

• Added @Nullable annotations to fields and constructor parameters (nodeId, nodeUri,
 payload)
• Added @Nullable return type annotations to getter methods
• Updated @SuppressWarnings annotation on fromJson method

java/src/org/openqa/selenium/grid/data/SessionEventData.java


9. java/src/org/openqa/selenium/grid/node/relay/RelaySessionFactory.java ✨ Enhancement +7/-6

Add JSpecify nullability annotations to relay session factory

• Added @Nullable annotations to field and constructor parameter (serviceStatusUrl,
 serviceStatusUri)
• Replaced Contents.string(response) with response::contentAsString method reference
• Added @Nullable return type annotation to createUrlFromUri method

java/src/org/openqa/selenium/grid/node/relay/RelaySessionFactory.java


10. java/src/org/openqa/selenium/grid/data/Slot.java ✨ Enhancement +7/-4

Add JSpecify nullability annotations to slot data class

• Added @Nullable annotations to field and constructor parameter (session)
• Added @Nullable return type annotation to getSession() method
• Updated toJson() method signature to use Map<String, @Nullable Object>
• Added @SuppressWarnings annotation to fromJson method

java/src/org/openqa/selenium/grid/data/Slot.java


11. java/src/org/openqa/selenium/grid/TemplateGridServerCommand.java ✨ Enhancement +10/-7

Add JSpecify nullability annotations and adjust visibility

• Changed Handlers class visibility from public to protected
• Added @Nullable annotations to field and constructor parameters (tcpTunnelResolver,
 websocketHandler)
• Changed constructor visibility from public to protected

java/src/org/openqa/selenium/grid/TemplateGridServerCommand.java


12. java/src/org/openqa/selenium/remote/RemoteLogs.java ✨ Enhancement +12/-12

Refactor log entry creation and improve type safety

• Refactored log entry creation to use stream API with map() and collect()
• Extracted createLogEntry() helper method for better code organization
• Simplified getAvailableLogTypes() by using executeRequired() instead of casting
• Removed unnecessary @SuppressWarnings("deprecation") annotation

java/src/org/openqa/selenium/remote/RemoteLogs.java


13. java/src/org/openqa/selenium/grid/config/MemoizedConfig.java ✨ Enhancement +3/-2

Add JSpecify nullability annotations to memoized config

• Added @Nullable annotations to return type and generic type parameter (`Optional<@Nullable
 String>, AtomicReference<@Nullable Exception>`)

java/src/org/openqa/selenium/grid/config/MemoizedConfig.java


14. java/src/org/openqa/selenium/manager/SeleniumManagerOutput.java ✨ Enhancement +16/-6

Add JSpecify nullability annotations to Selenium manager output

• Added @Nullable annotations to fields and method return types (logs, result, message,
 driverPath, browserPath)
• Added @Nullable return type annotations to getter methods

java/src/org/openqa/selenium/manager/SeleniumManagerOutput.java


15. java/src/org/openqa/selenium/grid/sessionmap/jdbc/JdbcBackedSessionMap.java ✨ Enhancement +7/-6

Add JSpecify nullability annotations and remove unused field

• Added @Nullable annotations to static fields (jdbcUser, jdbcUrl)
• Removed unused bus field and updated references to use parameter directly
• Added comment //noinspection DataFlowIssue for data flow analysis suppression

java/src/org/openqa/selenium/grid/sessionmap/jdbc/JdbcBackedSessionMap.java


16. java/src/org/openqa/selenium/grid/distributor/local/LocalGridModel.java ✨ Enhancement +5/-3

Add JSpecify nullability annotations to local grid model

• Added @Nullable annotations to method return types and parameters (getNode(), release(),
 setSession())
• Fixed typo in comment: "healthcheck" to "health check"

java/src/org/openqa/selenium/grid/distributor/local/LocalGridModel.java


17. java/src/org/openqa/selenium/grid/distributor/NodeRegistry.java ✨ Enhancement +3/-2

Add JSpecify nullability annotations to node registry interface

• Added @Nullable annotations to method parameters and return types (setSession(), getNode())

java/src/org/openqa/selenium/grid/distributor/NodeRegistry.java


18. java/src/org/openqa/selenium/grid/distributor/local/LocalDistributor.java ✨ Enhancement +3/-0

Add JSpecify nullability annotations to local distributor

• Added @Nullable annotations to method return types (reserveSlot(), getNodeFromURI())

java/src/org/openqa/selenium/grid/distributor/local/LocalDistributor.java


19. java/src/org/openqa/selenium/grid/node/k8s/OneShotNode.java ✨ Enhancement +8/-4

Add JSpecify nullability annotations to one-shot node

• Added @Nullable annotations to fields (driver, sessionId, client, capabilities)
• Added @Nullable return type annotations to methods (findClientField(), uploadFile(),
 downloadFile())

java/src/org/openqa/selenium/grid/node/k8s/OneShotNode.java


20. java/src/org/openqa/selenium/grid/data/SessionRequestCapability.java ✨ Enhancement +2/-6

Simplify JSON serialization and add annotations

• Simplified toJson() method to use Map.of() instead of creating and returning a HashMap
• Removed unnecessary imports (unmodifiableMap, HashMap)
• Added @SuppressWarnings annotation to fromJson method

java/src/org/openqa/selenium/grid/data/SessionRequestCapability.java


21. java/src/org/openqa/selenium/grid/node/local/LocalNode.java ✨ Enhancement +5/-3

Add JSpecify nullability annotations to local node

• Added @Nullable annotations to method parameters (healthCheck, id, slot)
• Updated toJson() method signature to use Map<String, @Nullable Object>

java/src/org/openqa/selenium/grid/node/local/LocalNode.java


22. java/src/org/openqa/selenium/grid/distributor/AddNode.java ✨ Enhancement +1/-3

Replace deprecated Contents.string with contentAsString

• Removed unused import of Contents.string
• Replaced string(req) with req.contentAsString() method call

java/src/org/openqa/selenium/grid/distributor/AddNode.java


23. java/src/org/openqa/selenium/grid/node/local/SessionSlot.java ✨ Enhancement +4/-2

Add JSpecify nullability annotations to session slot

• Added @Nullable annotations to field and method parameters (currentSession, nodeId,
 nodeUri)
• Added @Nullable return type annotation to getSession() method

java/src/org/openqa/selenium/grid/node/local/SessionSlot.java


24. java/src/org/openqa/selenium/SessionNotCreatedException.java ✨ Enhancement +4/-2

Add JSpecify nullability annotations to exception class

• Added @Nullable annotations to constructor parameters (msg, cause)

java/src/org/openqa/selenium/SessionNotCreatedException.java


25. java/src/org/openqa/selenium/ie/InternetExplorerOptions.java ✨ Enhancement +4/-4

Add JSpecify nullability annotations to IE options

• Added @Nullable annotations to field and method parameter types (ieOptions, value)
• Updated map type signatures to include @Nullable Object for values

java/src/org/openqa/selenium/ie/InternetExplorerOptions.java


26. java/src/org/openqa/selenium/grid/distributor/GridModel.java ✨ Enhancement +2/-1

Add JSpecify nullability annotations to grid model interface

• Added @Nullable annotations to method parameter (session)

java/src/org/openqa/selenium/grid/distributor/GridModel.java


27. java/src/org/openqa/selenium/grid/data/Session.java ✨ Enhancement +2/-1

Add annotations and enforce non-null capabilities reading

• Added @SuppressWarnings annotation to fromJson method
• Changed input.read() to input.readNonNull() for capabilities to enforce non-null contract

java/src/org/openqa/selenium/grid/data/Session.java


28. java/src/org/openqa/selenium/grid/node/docker/DockerOptions.java ✨ Enhancement +4/-0

Add JSpecify nullability annotations to Docker options

• Added @Nullable annotations to method return types (getApiVersion(), getVideoImage(),
 getAssetsPath())

java/src/org/openqa/selenium/grid/node/docker/DockerOptions.java


29. java/src/org/openqa/selenium/grid/sessionmap/redis/RedisBackedSessionMap.java ✨ Enhancement +4/-4

Remove unused field and add data flow suppression

• Removed unused bus field and updated references to use parameter directly
• Added comment //noinspection DataFlowIssue for data flow analysis suppression

java/src/org/openqa/selenium/grid/sessionmap/redis/RedisBackedSessionMap.java


30. java/src/org/openqa/selenium/grid/sessionmap/remote/RemoteSessionMap.java ✨ Enhancement +4/-1

Add JSpecify nullability annotations and enforce contracts

• Added @Nullable annotations to method return type (makeRequest())
• Added requireNonNull() call to enforce non-null contract for boolean result
• Added static import for requireNonNull

java/src/org/openqa/selenium/grid/sessionmap/remote/RemoteSessionMap.java


31. java/src/org/openqa/selenium/grid/node/kubernetes/KubernetesSession.java ✨ Enhancement +7/-6

Add JSpecify nullability annotations to Kubernetes session

• Added @Nullable annotations to fields and constructor parameters (assetsPath, videoFileName,
 portForward)

java/src/org/openqa/selenium/grid/node/kubernetes/KubernetesSession.java


32. java/src/org/openqa/selenium/grid/node/config/SessionCapabilitiesMutator.java ✨ Enhancement +6/-3

Improve null safety and code readability in capability mutator

• Extracted capability values to local variables for better null safety
• Added Require.nonNull() call to enforce non-null contract for VNC port
• Improved code readability by reducing repeated capability lookups

java/src/org/openqa/selenium/grid/node/config/SessionCapabilitiesMutator.java


33. java/src/org/openqa/selenium/grid/node/relay/RelayOptions.java ✨ Enhancement +3/-2

Add JSpecify nullability annotations and replace deprecated method

• Added @Nullable annotations to method return type (getServiceStatusUri())
• Removed unused import of Contents.string
• Replaced string(response) with response::contentAsString method reference

java/src/org/openqa/selenium/grid/node/relay/RelayOptions.java


34. java/src/org/openqa/selenium/grid/config/Config.java ✨ Enhancement +2/-1

Add JSpecify nullability annotations to config interface

• Added @Nullable annotations to default method return type (Optional<@Nullable String>)

java/src/org/openqa/selenium/grid/config/Config.java


35. java/src/org/openqa/selenium/cli/package-info.java 📦 Other +3/-0

Add package-level

• Added @NullMarked annotation to package for JSpecify nullability
• Added import statement for NullMarked annotation

java/src/org/openqa/selenium/cli/package-info.java


36. java/src/org/openqa/selenium/grid/web/package-info.java ✨ Enhancement +21/-0

Add JSpecify nullability annotations to grid web package

• Created new package-info file with @NullMarked annotation
• Imports NullMarked from org.jspecify.annotations
• Applies nullability annotations to the org.openqa.selenium.grid.web package

java/src/org/openqa/selenium/grid/web/package-info.java


37. java/test/org/openqa/selenium/grid/config/package-info.java ✨ Enhancement +21/-0

Add JSpecify nullability annotations to grid config test package

• Created new package-info file with @NullMarked annotation
• Imports NullMarked from org.jspecify.annotations
• Applies nullability annotations to the org.openqa.selenium.grid.config test package

java/test/org/openqa/selenium/grid/config/package-info.java


38. java/test/org/openqa/selenium/grid/data/package-info.java ✨ Enhancement +21/-0

Add JSpecify nullability annotations to grid data test package

• Created new package-info file with @NullMarked annotation
• Imports NullMarked from org.jspecify.annotations
• Applies nullability annotations to the org.openqa.selenium.grid.data test package

java/test/org/openqa/selenium/grid/data/package-info.java


39. java/test/org/openqa/selenium/grid/node/package-info.java ✨ Enhancement +21/-0

Add JSpecify nullability annotations to grid node test package

• Created new package-info file with @NullMarked annotation
• Imports NullMarked from org.jspecify.annotations
• Applies nullability annotations to the org.openqa.selenium.grid.node test package

java/test/org/openqa/selenium/grid/node/package-info.java


40. java/test/org/openqa/selenium/grid/router/package-info.java ✨ Enhancement +21/-0

Add JSpecify nullability annotations to grid router test package

• Created new package-info file with @NullMarked annotation
• Imports NullMarked from org.jspecify.annotations
• Applies nullability annotations to the org.openqa.selenium.grid.router test package

java/test/org/openqa/selenium/grid/router/package-info.java


41. java/test/org/openqa/selenium/grid/security/package-info.java ✨ Enhancement +21/-0

Add JSpecify nullability annotations to grid security test package

• Created new package-info file with @NullMarked annotation
• Imports NullMarked from org.jspecify.annotations
• Applies nullability annotations to the org.openqa.selenium.grid.security test package

java/test/org/openqa/selenium/grid/security/package-info.java


42. java/test/org/openqa/selenium/grid/server/package-info.java ✨ Enhancement +21/-0

Add JSpecify nullability annotations to grid server test package

• Created new package-info file with @NullMarked annotation
• Imports NullMarked from org.jspecify.annotations
• Applies nullability annotations to the org.openqa.selenium.grid.server test package

java/test/org/openqa/selenium/grid/server/package-info.java


43. java/src/org/openqa/selenium/manager/package-info.java ✨ Enhancement +21/-0

Add JSpecify nullability annotations to manager package

• Created new package-info file with @NullMarked annotation
• Imports NullMarked from org.jspecify.annotations
• Applies nullability annotations to the org.openqa.selenium.manager package

java/src/org/openqa/selenium/manager/package-info.java


44. java/src/org/openqa/selenium/grid/graphql/Types.java ✨ Enhancement +3/-5

Add nullability annotations to GraphQL Types class

• Added @Nullable import from org.jspecify.annotations
• Removed redundant null check in parseValue method for URI type
• Added @Nullable annotation to parseValue method return type and parameter for URL type

java/src/org/openqa/selenium/grid/graphql/Types.java


45. java/src/org/openqa/selenium/grid/distributor/local/LocalNodeRegistry.java ✨ Enhancement +3/-1

Add nullability annotations to LocalNodeRegistry class

• Added @Nullable import from org.jspecify.annotations
• Added @Nullable annotation to Session parameter in setSession method
• Added @Nullable annotation to return type of getNode method

java/src/org/openqa/selenium/grid/distributor/local/LocalNodeRegistry.java


46. java/src/org/openqa/selenium/grid/config/ConfigException.java ✨ Enhancement +3/-1

Add nullability annotation to ConfigException constructor

• Added @Nullable import from org.jspecify.annotations
• Added @Nullable annotation to Throwable parameter in constructor

java/src/org/openqa/selenium/grid/config/ConfigException.java


47. java/src/org/openqa/selenium/grid/log/LoggingOptions.java ✨ Enhancement +3/-1

Add nullability annotations to LoggingOptions class

• Added @Nullable import from org.jspecify.annotations
• Added @Nullable annotation to getLogEncoding method return type
• Added @Nullable annotation to encoding parameter in configureLogEncoding method

java/src/org/openqa/selenium/grid/log/LoggingOptions.java


48. java/src/org/openqa/selenium/manager/SeleniumManager.java ✨ Enhancement +6/-3

Add nullability annotations to SeleniumManager class fields

• Added @Nullable import from org.jspecify.annotations
• Added @Nullable annotation to static manager field
• Added @Nullable annotation to managerPath field
• Added @Nullable annotation to binary field

java/src/org/openqa/selenium/manager/SeleniumManager.java


49. java/test/org/openqa/selenium/grid/distributor/AddingNodesTest.java ✨ Enhancement +3/-2

Add nullability annotations to AddingNodesTest class

• Added @Nullable import from org.jspecify.annotations
• Added @Nullable annotation to distributor field
• Added @Nullable annotation to running field in CustomNode inner class

java/test/org/openqa/selenium/grid/distributor/AddingNodesTest.java


50. java/src/org/openqa/selenium/grid/sessionmap/local/LocalSessionMap.java ✨ Enhancement +3/-0

Add nullability annotations to LocalSessionMap class

• Added @Nullable import from org.jspecify.annotations
• Added @Nullable annotation to get method return type in IndexedSessionMap
• Added @Nullable annotation to remove method return type in IndexedSessionMap

java/src/org/openqa/selenium/grid/sessionmap/local/LocalSessionMap.java


51. java/src/org/openqa/selenium/grid/jmx/MBean.java ✨ Enhancement +2/-2

Add nullability annotations to MBean class

• Added @Nullable annotation to attributes array variable
• Added @Nullable annotation to attributes parameter in getAttributes method

java/src/org/openqa/selenium/grid/jmx/MBean.java


52. java/src/org/openqa/selenium/grid/node/docker/DockerSession.java ✨ Enhancement +3/-2

Add nullability annotations to DockerSession class

• Added @Nullable import from org.jspecify.annotations
• Added @Nullable annotation to videoContainer field
• Added @Nullable annotation to videoContainer parameter in constructor

java/src/org/openqa/selenium/grid/node/docker/DockerSession.java


53. java/src/org/openqa/selenium/grid/data/NodeStatus.java ✨ Enhancement +2/-1

Make NodeStatus fromJson method private with suppressed warnings

• Changed fromJson method from public to private
• Added @SuppressWarnings annotation for unused and DataFlowIssue warnings

java/src/org/openqa/selenium/grid/data/NodeStatus.java


54. java/src/org/openqa/selenium/grid/data/SessionCreatedData.java ✨ Enhancement +1/-0

Add suppressed warnings to SessionCreatedData fromJson method

• Added @SuppressWarnings annotation to fromJson method for unused and DataFlowIssue warnings

java/src/org/openqa/selenium/grid/data/SessionCreatedData.java


55. java/src/org/openqa/selenium/grid/web/NoHandler.java ✨ Enhancement +2/-1

Add nullability annotation to NoHandler response map

• Added @Nullable import from org.jspecify.annotations
• Added @Nullable annotation to Object type in HashMap for response map

java/src/org/openqa/selenium/grid/web/NoHandler.java


56. java/src/org/openqa/selenium/grid/data/SessionRequest.java ✨ Enhancement +1/-0

Add suppressed warnings to SessionRequest fromJson method

• Added @SuppressWarnings annotation to fromJson method for unused and DataFlowIssue warnings

java/src/org/openqa/selenium/grid/data/SessionRequest.java


57. java/src/org/openqa/selenium/grid/node/httpd/NodeServer.java ✨ Enhancement +3/-2

Add nullability annotations to NodeServer class fields

• Added @Nullable import from org.jspecify.annotations
• Added @Nullable annotation to node field
• Added @Nullable annotation to bus field

java/src/org/openqa/selenium/grid/node/httpd/NodeServer.java


58. java/src/org/openqa/selenium/grid/server/EventBusOptions.java ✨ Enhancement +2/-1

Add nullability annotation to EventBusOptions bus field

• Added @Nullable import from org.jspecify.annotations
• Added @Nullable annotation to volatile bus field

java/src/org/openqa/selenium/grid/server/EventBusOptions.java


59. java/src/org/openqa/selenium/grid/jmx/JMXHelper.java ✨ Enhancement +1/-3

Update nullability annotations in JMXHelper class

• Removed @NullMarked class-level annotation
• Added @Nullable annotation to objectName parameter in unregister method

java/src/org/openqa/selenium/grid/jmx/JMXHelper.java


60. java/src/org/openqa/selenium/grid/node/remote/RemoteNode.java ✨ Enhancement +2/-2

Add non-null assertions to RemoteNode class

• Wrapped Values.get result with Require.nonNull in getSession method
• Changed in.read to in.readNonNull for NodeStatus deserialization

java/src/org/openqa/selenium/grid/node/remote/RemoteNode.java


61. java/src/org/openqa/selenium/grid/sessionqueue/local/LocalNewSessionQueue.java ✨ Enhancement +3/-1

Add nullability annotation to LocalNewSessionQueue jmxBean field

• Added @Nullable import from org.jspecify.annotations
• Added @Nullable annotation to jmxBean field

java/src/org/openqa/selenium/grid/sessionqueue/local/LocalNewSessionQueue.java


62. java/src/org/openqa/selenium/grid/package-info.java ✨ Enhancement +4/-2

Add JSpecify nullability annotations to grid package

• Moved package declaration to end of file after documentation
• Added @NullMarked annotation to package
• Added import for NullMarked from org.jspecify.annotations

java/src/org/openqa/selenium/grid/package-info.java


63. java/src/org/openqa/selenium/grid/data/NewSessionResponse.java ✨ Enhancement +1/-0

Add suppressed warnings to NewSessionResponse fromJson method

• Added @SuppressWarnings annotation to fromJson method for unused and DataFlowIssue warnings

java/src/org/openqa/selenium/grid/data/NewSessionResponse.java


64. java/src/org/openqa/selenium/grid/graphql/SessionData.java ✨ Enhancement +2/-0

Add nullability annotation to SessionData findSession method

• Added @Nullable import from org.jspecify.annotations
• Added @Nullable annotation to findSession method return type

java/src/org/openqa/selenium/grid/graphql/SessionData.java


65. java/src/org/openqa/selenium/grid/node/Node.java ✨ Enhancement +3/-0

Add nullability annotations to Node abstract methods

• Added @Nullable import from org.jspecify.annotations
• Added @Nullable annotation to uploadFile abstract method return type
• Added @Nullable annotation to downloadFile abstract method return type

java/src/org/openqa/selenium/grid/node/Node.java


66. java/src/org/openqa/selenium/grid/security/SecretOptions.java ✨ Enhancement +2/-0

Add nullability annotation to SecretOptions method

• Added @Nullable import from org.jspecify.annotations
• Added @Nullable annotation to getServerAuthentication method return type

java/src/org/openqa/selenium/grid/security/SecretOptions.java


67. java/src/org/openqa/selenium/internal/Debug.java ✨ Enhancement +1/-2

Convert static logger field to local variable in Debug class

• Removed static seleniumLogger field declaration
• Changed seleniumLogger to local variable in configureLogger method

java/src/org/openqa/selenium/internal/Debug.java


68. java/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java ✨ Enhancement +2/-0

Add nullability annotation to DriverServiceSessionFactory method

• Added @Nullable import from org.jspecify.annotations
• Added @Nullable annotation to getHost method return type

java/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java


69. java/src/org/openqa/selenium/grid/security/BasicAuthenticationFilter.java ✨ Enhancement +2/-1

Add nullability annotation to BasicAuthenticationFilter method

• Added @Nullable import from org.jspecify.annotations
• Added @Nullable annotation to auth parameter in isAuthorized method

java/src/org/openqa/selenium/grid/security/BasicAuthenticationFilter.java


70. java/src/org/openqa/selenium/grid/web/MergedResource.java ✨ Enhancement +2/-1

Add nullability annotation to MergedResource constructor

• Added @Nullable import from org.jspecify.annotations
• Added @Nullable annotation to next parameter in private constructor

java/src/org/openqa/selenium/grid/web/MergedResource.java


71. java/src/org/openqa/selenium/grid/server/BaseServerOptions.java ✨ Enhancement +2/-1

Add nullability annotation to BaseServerOptions method

• Added @Nullable import from org.jspecify.annotations
• Added @Nullable annotation to String type in Optional return type of getHostname method

java/src/org/openqa/selenium/grid/server/BaseServerOptions.java


72. java/src/org/openqa/selenium/grid/data/CreateSessionResponse.java ✨ Enhancement +1/-0

Add suppressed warnings to CreateSessionResponse fromJson method

• Added @SuppressWarnings annotation to fromJson method for unused and DataFlowIssue warnings

java/src/org/openqa/selenium/grid/data/CreateSessionResponse.java


73. java/test/org/openqa/selenium/remote 📦 Other +0/-0

java/test/org/openqa/selenium/remote


74. java/src/org/openqa/selenium/MutableCapabilities.java Additional files +1/-1

...

java/src/org/openqa/selenium/MutableCapabilities.java


75. java/src/org/openqa/selenium/cli/BUILD.bazel Additional files +1/-0

...

java/src/org/openqa/selenium/cli/BUILD.bazel


76. java/src/org/openqa/selenium/edge/package-info.java Additional files +0/-29

...

java/src/org/openqa/selenium/edge/package-info.java


77. java/src/org/openqa/selenium/federatedcredentialmanagement/package-info.java Additional files +0/-29

...

java/src/org/openqa/selenium/federatedcredentialmanagement/package-info.java


78. java/src/org/openqa/selenium/grid/BUILD.bazel Additional files +2/-0

...

java/src/org/openqa/selenium/grid/BUILD.bazel


79. java/src/org/openqa/selenium/grid/commands/InfoCommand.java Additional files +0/-2

...

java/src/org/openqa/selenium/grid/commands/InfoCommand.java


80. java/src/org/openqa/selenium/grid/commands/package-info.java Additional files +21/-0

...

java/src/org/openqa/selenium/grid/commands/package-info.java


81. java/src/org/openqa/selenium/grid/component/BUILD.bazel Additional files +2/-0

...

java/src/org/openqa/selenium/grid/component/BUILD.bazel


82. java/src/org/openqa/selenium/grid/component/package-info.java Additional files +21/-0

...

java/src/org/openqa/selenium/grid/component/package-info.java


83. java/src/org/openqa/selenium/grid/config/AnnotatedConfig.java Additional files +3/-1

...

java/src/org/openqa/selenium/grid/config/AnnotatedConfig.java


84. java/src/org/openqa/selenium/grid/config/BUILD.bazel Additional files +1/-0

...

java/src/org/openqa/selenium/grid/config/BUILD.bazel


85. java/src/org/openqa/selenium/grid/config/ConcatenatingConfig.java Additional files +2/-1

...

java/src/org/openqa/selenium/grid/config/ConcatenatingConfig.java


86. java/src/org/openqa/selenium/grid/config/package-info.java Additional files +21/-0

...

java/src/org/openqa/selenium/grid/config/package-info.java


87. java/src/org/openqa/selenium/grid/data/BUILD.bazel Additional files +2/-0

...

java/src/org/openqa/selenium/grid/data/BUILD.bazel


88. java/src/org/openqa/selenium/grid/data/CapabilityCount.java Additional files +1/-0

...

java/src/org/openqa/selenium/grid/data/CapabilityCount.java


89. java/src/org/openqa/selenium/grid/data/CreateSessionRequest.java Additional files +1/-0

...

java/src/org/openqa/selenium/grid/data/CreateSessionRequest.java


90. java/src/org/openqa/selenium/grid/data/DistributorStatus.java Additional files +1/-0

...

java/src/org/openqa/selenium/grid/data/DistributorStatus.java


91. java/src/org/openqa/selenium/grid/data/NewSessionErrorResponse.java Additional files +1/-0

...

java/src/org/openqa/selenium/grid/data/NewSessionErrorResponse.java


92. java/src/org/openqa/selenium/grid/data/NodeId.java Additional files +1/-0

...

java/src/org/openqa/selenium/grid/data/NodeId.java


93. java/src/org/openqa/selenium/grid/data/RequestId.java Additional files +1/-0

...

java/src/org/openqa/selenium/grid/data/RequestId.java


94. java/src/org/openqa/selenium/grid/data/SessionRemovalInfo.java Additional files +3/-2

...

java/src/org/openqa/selenium/grid/data/SessionRemovalInfo.java


95. java/src/org/openqa/selenium/grid/data/SlotId.java Additional files +1/-0

...

java/src/org/openqa/selenium/grid/data/SlotId.java


96. java/src/org/openqa/selenium/grid/data/package-info.java Additional files +21/-0

...

java/src/org/openqa/selenium/grid/data/package-info.java


97. java/src/org/openqa/selenium/grid/distributor/BUILD.bazel Additional files +1/-0

...

java/src/org/openqa/selenium/grid/distributor/BUILD.bazel


98. java/src/org/openqa/selenium/grid/distributor/config/BUILD.bazel Additional files +1/-0

...

java/src/org/openqa/selenium/grid/distributor/config/BUILD.bazel


99. java/src/org/openqa/selenium/grid/distributor/config/package-info.java Additional files +21/-0

...

java/src/org/openqa/selenium/grid/distributor/config/package-info.java


100. java/src/org/openqa/selenium/grid/distributor/httpd/BUILD.bazel Additional files +1/-0

...

java/src/org/openqa/selenium/grid/distributor/httpd/BUILD.bazel


101. java/src/org/openqa/selenium/grid/distributor/httpd/package-info.java Additional files +21/-0

...

java/src/org/openqa/selenium/grid/distributor/httpd/package-info.java


102. java/src/org/openqa/selenium/grid/distributor/local/BUILD.bazel Additional files +1/-0

...

java/src/org/openqa/selenium/grid/distributor/local/BUILD.bazel


103. java/src/org/openqa/selenium/grid/distributor/local/package-info.java Additional files +21/-0

...

java/src/org/openqa/selenium/grid/distributor/local/package-info.java


104. java/src/org/openqa/selenium/grid/distributor/package-info.java Additional files +3/-0

...

java/src/org/openqa/selenium/grid/distributor/package-info.java


105. java/src/org/openqa/selenium/grid/distributor/remote/BUILD.bazel Additional files

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Mar 4, 2026

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (2) 📎 Requirement gaps (0)

Grey Divider


Action required

1. Handlers made protected 📘 Rule violation ✓ Correctness
Description
TemplateGridServerCommand.Handlers and its constructors were changed from public to protected,
preventing external callers from referencing or instantiating it. This is an API/ABI breaking change
without a deprecation path.
Code

java/src/org/openqa/selenium/grid/TemplateGridServerCommand.java[R95-114]

+  protected abstract static class Handlers implements Closeable {
    public final HttpHandler httpHandler;
    public final BiFunction<String, Consumer<Message>, Optional<Consumer<Message>>>
        websocketHandler;

    /** Optional resolver for direct TCP tunnel of WebSocket connections. May be null. */
-    public final Function<String, Optional<URI>> tcpTunnelResolver;
+    public final @Nullable Function<String, Optional<URI>> tcpTunnelResolver;

-    public Handlers(
+    protected Handlers(
        HttpHandler http,
-        BiFunction<String, Consumer<Message>, Optional<Consumer<Message>>> websocketHandler) {
+        @Nullable BiFunction<String, Consumer<Message>, Optional<Consumer<Message>>>
+            websocketHandler) {
      this(http, websocketHandler, null);
    }

-    public Handlers(
+    protected Handlers(
        HttpHandler http,
-        BiFunction<String, Consumer<Message>, Optional<Consumer<Message>>> websocketHandler,
-        Function<String, Optional<URI>> tcpTunnelResolver) {
+        @Nullable BiFunction<String, Consumer<Message>, Optional<Consumer<Message>>>
+            websocketHandler,
+        @Nullable Function<String, Optional<URI>> tcpTunnelResolver) {
Evidence
The checklist requires preserving public APIs unless explicitly deprecated/removed; the diff reduces
visibility of a previously public nested type and constructors to protected, which breaks
downstream compilation and usage.

AGENTS.md
AGENTS.md
java/src/org/openqa/selenium/grid/TemplateGridServerCommand.java[95-114]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`TemplateGridServerCommand.Handlers` and its constructors were changed from `public` to `protected`, which is a breaking change for any downstream code that referenced/instantiated this type.

## Issue Context
This PR appears focused on nullability annotations, but reducing access modifiers removes public surface area without deprecation/migration guidance.

## Fix Focus Areas
- java/src/org/openqa/selenium/grid/TemplateGridServerCommand.java[95-114]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. fromJson made private 📘 Rule violation ✓ Correctness
Description
NodeStatus.fromJson(JsonInput) was changed from public static to private static, removing a
previously public entry point. This is an API/ABI breaking change without deprecation or an
alternative.
Code

java/src/org/openqa/selenium/grid/data/NodeStatus.java[R72-73]

+  @SuppressWarnings({"unused", "DataFlowIssue"})
+  private static NodeStatus fromJson(JsonInput input) {
Evidence
The checklist forbids breaking public APIs without an explicit compatibility plan; the diff changes
fromJson visibility to private, which prevents external callers from invoking it.

AGENTS.md
AGENTS.md
java/src/org/openqa/selenium/grid/data/NodeStatus.java[72-73]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`NodeStatus.fromJson(JsonInput)` was changed from `public static` to `private static`, which breaks any downstream code calling it.

## Issue Context
If the goal is to adjust nullness/flow analysis, preserve the public API and move suppression/logic into an internal helper method instead of removing access.

## Fix Focus Areas
- java/src/org/openqa/selenium/grid/data/NodeStatus.java[72-73]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@asolntsev asolntsev changed the title Nullability in grid [java] specify nullability in org.openqa.selenium.grid.* packages Mar 4, 2026
@asolntsev asolntsev merged commit 41e422a into SeleniumHQ:trunk Mar 5, 2026
51 of 52 checks passed
@asolntsev asolntsev deleted the nullability-in-grid branch March 5, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-grid Everything grid and server related C-java Java Bindings I-enhancement Something could be better

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants