Use volatile for subscriber in base publishers

Issue: SPR-16207
This commit is contained in:
Rossen Stoyanchev
2017-11-21 22:57:15 -05:00
parent b89a48a703
commit 06b2ab3908
2 changed files with 7 additions and 7 deletions

View File

@@ -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...

View File

@@ -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;