@@ -394,7 +394,7 @@ protected AmqpChannelProcessor<RequestResponseChannel> createRequestResponseChan
394
394
})
395
395
.repeat ();
396
396
397
- return createChannel . takeUntilOther ( Mono . firstWithSignal ( isClosedMono . asMono (), shutdownSignalSink . asMono ()))
397
+ return createChannel
398
398
.subscribeWith (new AmqpChannelProcessor <>(connectionId , entityPath ,
399
399
channel -> channel .getEndpointStates (), retryPolicy ,
400
400
new ClientLogger (RequestResponseChannel .class + ":" + entityPath )));
@@ -469,7 +469,11 @@ private synchronized void closeConnectionWork() {
469
469
final ArrayList <Mono <Void >> closingSessions = new ArrayList <>();
470
470
sessionMap .values ().forEach (link -> closingSessions .add (link .isClosed ()));
471
471
472
- final Mono <Void > closedExecutor = executor != null ? executor .closeAsync () : Mono .empty ();
472
+ final Mono <Void > closedExecutor = executor != null ? Mono .defer (() -> {
473
+ synchronized (this ) {
474
+ return executor .closeAsync ();
475
+ }
476
+ }) : Mono .empty ();
473
477
474
478
// Close all the children.
475
479
final Mono <Void > closeSessionsMono = Mono .when (closingSessions )
@@ -531,7 +535,11 @@ private synchronized Connection getOrCreateConnection() throws IOException {
531
535
532
536
// To avoid inconsistent synchronization of executor, we set this field with the closeAsync method.
533
537
// It will not be kicked off until subscribed to.
534
- final Mono <Void > executorCloseMono = executor .closeAsync ();
538
+ final Mono <Void > executorCloseMono = Mono .defer (() -> {
539
+ synchronized (this ) {
540
+ return executor .closeAsync ();
541
+ }
542
+ });
535
543
reactorProvider .getReactorDispatcher ().getShutdownSignal ()
536
544
.flatMap (signal -> {
537
545
logger .info ("Shutdown signal received from reactor provider." );
0 commit comments