Address NullAway warnings and refine StepVerifier nullability#4126
Address NullAway warnings and refine StepVerifier nullability#4126
Conversation
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
…l actual Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
| return; | ||
| } | ||
| queue.offer(buffers.remove(idx)); | ||
| queue.offer(bufs.remove(idx)); |
Check notice
Code scanning / CodeQL
Ignored error status of call Note
| break; | ||
| } | ||
|
|
||
| assert next != null && next.value != null : "next and next.value must not be null"; |
Check warning
Code scanning / CodeQL
Useless null check Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the problem, the unnecessary redundancy in the assertion at line 241 should be eliminated. Specifically, the check for next != null is not needed as the control flow guarantees next is never null at this point. The best way to fix this without changing existing functionality is:
- In reactor-core/src/main/java/reactor/core/publisher/FluxReplay.java at line 241, change
assert next != null && next.value != null : "next and next.value must not be null";toassert next.value != null : "next.value must not be null"; - No additional imports or method changes are required.
| @@ -238,7 +238,7 @@ | ||
| break; | ||
| } | ||
|
|
||
| assert next != null && next.value != null : "next and next.value must not be null"; | ||
| assert next.value != null : "next.value must not be null"; | ||
| a.onNext(next.value); | ||
|
|
||
| e++; |
| break; | ||
| } | ||
|
|
||
| assert next != null && next.value != null : "next and next.value must not be null"; |
Check warning
Code scanning / CodeQL
Useless null check Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the problem, remove the useless check for next != null in the assertion at line 882. Since the empty case was already handled, the assertion only needs to check that next.value != null. No new methods, imports, or definitions are needed. Only alter the relevant assertion in reactor-core/src/main/java/reactor/core/publisher/FluxReplay.java.
| @@ -879,7 +879,7 @@ | ||
| break; | ||
| } | ||
|
|
||
| assert next != null && next.value != null : "next and next.value must not be null"; | ||
| assert next.value != null : "next.value must not be null"; | ||
| a.onNext(next.value); | ||
|
|
||
| e++; |
| } | ||
|
|
||
| // NullAway issue? | ||
| assert si != null : "si can not be null here"; |
Check warning
Code scanning / CodeQL
Useless null check Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
The best fix is to remove the redundant assertion statement on line 169: assert si != null : "si can not be null here";. This will clean up the code, improve readability, and avoid confusion or misleading logic. All other functionality is preserved. No other definitions or imports are needed.
Make this change only in reactor-core/src/main/java/reactor/core/publisher/FluxSwitchMapNoPrefetch.java.
| @@ -166,7 +166,6 @@ | ||
| } | ||
|
|
||
| // NullAway issue? | ||
| assert si != null : "si can not be null here"; | ||
| final int nextIndex = si.index + 1; | ||
| final SwitchMapInner<T, R> nsi = new SwitchMapInner<>(this, this.actual, nextIndex, this.logger); | ||
|
|
| FluxPublish.PubSubInner<T>[] a = subscribers; | ||
|
|
||
| if (a != EMPTY && !empty) { | ||
| assert q != null : "q can not be null when !empty"; |
Check warning
Code scanning / CodeQL
Useless null check Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the problem, remove the unnecessary assertion assert q != null : "q can not be null when !empty"; on line 410. This will clean up the code by eliminating misleading checks, reducing clutter, and making intent clearer, as the previous guard ensures this case is impossible.
No imports or other definitions are needed for this edit. Only the code in the vicinity of line 410, in the drain() method of reactor-core/src/main/java/reactor/core/publisher/SinkManyEmitterProcessor.java, needs to be changed.
| @@ -407,7 +407,6 @@ | ||
| FluxPublish.PubSubInner<T>[] a = subscribers; | ||
|
|
||
| if (a != EMPTY && !empty) { | ||
| assert q != null : "q can not be null when !empty"; | ||
| long maxRequested = Long.MAX_VALUE; | ||
|
|
||
| int len = a.length; |
This PR addresses the remaining NullAway warnings left after #4091.
It also contains public API refinenements around
StepVerifierandTestPublisherfrom reactor-test to allow verifying non-compliantPublishers against null values.Follow-up on #878