From fd240b3b8679c699808baf7f4c94263d0e8e0e9f Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Fri, 12 Jan 2024 17:15:06 +0000 Subject: [PATCH] Double-checked lock in ChannelSendOperator#request Closes gh-31865 --- .../handler/invocation/reactive/ChannelSendOperator.java | 4 ++++ .../http/server/reactive/ChannelSendOperator.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/ChannelSendOperator.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/ChannelSendOperator.java index 108d149299..ddcf7e709c 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/ChannelSendOperator.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/ChannelSendOperator.java @@ -281,6 +281,10 @@ class ChannelSendOperator extends Mono implements Scannable { return; } synchronized (this) { + if (this.state == State.READY_TO_WRITE) { + s.request(n); + return; + } if (this.writeSubscriber != null) { if (this.state == State.EMITTING_CACHED_SIGNALS) { this.demandBeforeReadyToWrite = n; diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ChannelSendOperator.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ChannelSendOperator.java index da46443edc..6b5e409595 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ChannelSendOperator.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ChannelSendOperator.java @@ -273,6 +273,10 @@ public class ChannelSendOperator extends Mono implements Scannable { return; } synchronized (this) { + if (this.state == State.READY_TO_WRITE) { + s.request(n); + return; + } if (this.writeSubscriber != null) { if (this.state == State.EMITTING_CACHED_SIGNALS) { this.demandBeforeReadyToWrite = n;