diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerReadPublisher.java b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerReadPublisher.java index c707f4865e..29e7a202fc 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerReadPublisher.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerReadPublisher.java @@ -52,17 +52,17 @@ public abstract class AbstractListenerReadPublisher implements Publisher { private volatile long demand; - private volatile boolean completionBeforeDemand; - - @Nullable - private volatile Throwable errorBeforeDemand; - @SuppressWarnings("rawtypes") private static final AtomicLongFieldUpdater DEMAND_FIELD_UPDATER = AtomicLongFieldUpdater.newUpdater(AbstractListenerReadPublisher.class, "demand"); @Nullable - private Subscriber subscriber; + private volatile Subscriber subscriber; + + private volatile boolean completionBeforeDemand; + + @Nullable + private volatile Throwable errorBeforeDemand; // Publisher implementation... diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/WriteResultPublisher.java b/spring-web/src/main/java/org/springframework/http/server/reactive/WriteResultPublisher.java index 1d3dab4a74..189d342889 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/WriteResultPublisher.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/WriteResultPublisher.java @@ -43,7 +43,7 @@ class WriteResultPublisher implements Publisher { private final AtomicReference state = new AtomicReference<>(State.UNSUBSCRIBED); @Nullable - private Subscriber subscriber; + private volatile Subscriber subscriber; private volatile boolean completedBeforeSubscribed;