Skip to content

Commit

Permalink
Suppress the nullability check for lazy initialised field (#278)
Browse files Browse the repository at this point in the history
Signed-off-by: Violeta Georgieva <[email protected]>
  • Loading branch information
violetagg authored Feb 12, 2025
1 parent 24cae73 commit 5758316
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions reactor-pool/src/main/java/reactor/pool/SimpleDequePool.java
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,11 @@ private static final class QueuePoolRecyclerInner<T>
final SimpleDequePool<T> pool;

//poolable can be checked for null to protect against protocol errors
@Nullable QueuePooledRef<T> pooledRef;
@Nullable Subscription upstream;
long start;
@Nullable QueuePooledRef<T> pooledRef;
//upstream is initialized on onSubscribe,
//the current usage doesn't require checking it for null value
@SuppressWarnings("NullAway.Init") Subscription upstream;
long start;

//once protects against multiple requests
volatile int once;
Expand Down Expand Up @@ -831,8 +833,9 @@ public void onSubscribe(Subscription s) {

@Override
public void request(long l) {
assert upstream != null;
if (Operators.validate(l)) {
//upstream is initialized on onSubscribe,
//the current usage doesn't require checking it for null value
upstream.request(l);
// we decrement ACQUIRED EXACTLY ONCE to indicate that the poolable was released by the user
if (ONCE.compareAndSet(this, 0, 1)) {
Expand Down

0 comments on commit 5758316

Please sign in to comment.