Browse Source

Use volatile for subscriber in base publishers

Issue: SPR-16207
pull/1603/head
Rossen Stoyanchev 7 years ago
parent
commit
06b2ab3908
  1. 12
      spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerReadPublisher.java
  2. 2
      spring-web/src/main/java/org/springframework/http/server/reactive/WriteResultPublisher.java

12
spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerReadPublisher.java

@ -52,17 +52,17 @@ public abstract class AbstractListenerReadPublisher<T> implements Publisher<T> { @@ -52,17 +52,17 @@ public abstract class AbstractListenerReadPublisher<T> implements Publisher<T> {
private volatile long demand;
private volatile boolean completionBeforeDemand;
@Nullable
private volatile Throwable errorBeforeDemand;
@SuppressWarnings("rawtypes")
private static final AtomicLongFieldUpdater<AbstractListenerReadPublisher> DEMAND_FIELD_UPDATER =
AtomicLongFieldUpdater.newUpdater(AbstractListenerReadPublisher.class, "demand");
@Nullable
private Subscriber<? super T> subscriber;
private volatile Subscriber<? super T> subscriber;
private volatile boolean completionBeforeDemand;
@Nullable
private volatile Throwable errorBeforeDemand;
// Publisher implementation...

2
spring-web/src/main/java/org/springframework/http/server/reactive/WriteResultPublisher.java

@ -43,7 +43,7 @@ class WriteResultPublisher implements Publisher<Void> { @@ -43,7 +43,7 @@ class WriteResultPublisher implements Publisher<Void> {
private final AtomicReference<State> state = new AtomicReference<>(State.UNSUBSCRIBED);
@Nullable
private Subscriber<? super Void> subscriber;
private volatile Subscriber<? super Void> subscriber;
private volatile boolean completedBeforeSubscribed;

Loading…
Cancel
Save