[java] specify nullability in other java packages - #17194
Conversation
Review Summary by QodoAdd JSpecify nullability annotations to events, interactions, and logging packages
WalkthroughsDescription• Add JSpecify @NullMarked annotations to events, interactions, and logging packages • Remove class-level @NullMarked annotations, replace with package-level declarations • Improve nullability handling in UnboundZmqEventBus by making sockets final and initializing in constructor • Update Encodable interface to use @Nullable Object in return types for better null-safety • Add @NullMarked method annotations to logging and remote driver implementations File Changes1. java/src/org/openqa/selenium/events/package-info.java
|
Code Review by Qodo
1. RejectedEvent may be null
|
Partially implements SeleniumHQ#14291
Partially implements SeleniumHQ#14291
Partially implements SeleniumHQ#14291
Partially implements SeleniumHQ#14291
Partially implements SeleniumHQ#14291
Partially implements SeleniumHQ#14291
…tor` Partially implements SeleniumHQ#14291
Partially implements SeleniumHQ#14291
Review Summary by Qodo
WalkthroughsDescription• Add JSpecify nullability annotations across multiple Java packages • Create package-info.java files with @NullMarked for 8 packages • Refactor code to use Require utility for validation • Improve Lazy class with exception handling and thread safety • Update BUILD.bazel files to include jspecify dependency File Changes1. java/src/org/openqa/selenium/Architecture.java
|
Code Review by Qodo
1. Lazy now final, new Supplier
|
| public final class Lazy<T> { | ||
|
|
||
| @Nullable private volatile T value; | ||
| private final Object lock = new Object(); | ||
| private volatile @Nullable T value; | ||
| private final Supplier<T> supplier; | ||
|
|
||
| private Lazy(Supplier<T> supplier) { | ||
| this.supplier = supplier; | ||
| } | ||
|
|
||
| public Optional<T> getIfInitialized() { | ||
| return Optional.ofNullable(value); | ||
| return value == null ? Optional.empty() : Optional.ofNullable(value); | ||
| } | ||
|
|
||
| public T get() { | ||
| if (value == null) { | ||
| synchronized (this) { | ||
| synchronized (lock) { | ||
| if (value == null) { | ||
| value = supplier.get(); | ||
| try { | ||
| value = supplier.get(); | ||
| } catch (Exception e) { | ||
| throw new InitializationException(e); | ||
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
1. lazy now final, new supplier 📘 Rule violation ✓ Correctness
Lazy was made final and its factory now accepts a new nested Lazy.Supplier instead of java.util.function.Supplier, breaking source compatibility for callers that subclass Lazy or pass a java.util.function.Supplier variable. This violates the requirement to maintain backwards compatible public APIs/ABIs for upgrades.
Agent Prompt
## Issue description
`org.openqa.selenium.concurrent.Lazy` introduces breaking API changes by becoming `final` and by changing its public factory parameter type from `java.util.function.Supplier` to a new nested `Lazy.Supplier`.
## Issue Context
This is a public type under `org.openqa.selenium.concurrent` and can be used by external callers. Callers that subclass `Lazy` or that store suppliers in `java.util.function.Supplier<T>` variables may fail to compile after upgrading.
## Fix Focus Areas
- java/src/org/openqa/selenium/concurrent/Lazy.java[25-61]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
* specify nullability in package `org.openqa.selenium.events` * specify nullability in package `org.openqa.selenium.interactions` * specify nullability in package `org.openqa.selenium.logging` * specify nullability in package `org.openqa.selenium.netty.server` * specify nullability in package `org.openqa.selenium.redis` * specify nullability in package `org.openqa.selenium.status` * specify nullability in package `org.openqa.selenium.virtualauthenticator` * specify nullability in package `org.openqa.selenium` Partially implements SeleniumHQ#14291
🔗 Related Issues
Partially implements #14291
💥 What does this PR do?
Adds JSpecify nullability annotations to other packages:
org.openqa.selenium.events.*org.openqa.selenium.interactions.*org.openqa.selenium.netty.*org.openqa.selenium.redis.*org.openqa.selenium.status.*org.openqa.selenium.virtualauthenticator.*🔄 Types of changes