Skip to content

Recursive subscribe/loop during service shutdown #4124

@EricY019

Description

@EricY019

Description

During a Spring context close, a pipeline that uses Mono.when(...) can intermittently enter a recursive subscribe/loop. The logs repeatedly show MonoWhen$WhenInner.currentContext alternating with Operators.reportThrowInSubscribe and Mono.subscribe, suggesting a subscription cycle during termination.

Expected Behavior

Shutdown should complete outstanding signals and release resources in order.
No recursive calls to currentContext/subscribe or subscription loops should occur.

Actual Behavior

Repeated stack traces during shutdown indicate recursive/looping subscriptions.

Image

Steps to Reproduce

@Test
void reproCase() {

}

Possible Solution

Your Environment

  • Reactor version(s) used: 3.7.8
  • Other relevant libraries versions (eg. netty, ...):
  • JVM version (java -version):
    openjdk version "21.0.7" 2025-04-15 LTS
    OpenJDK Runtime Environment Zulu21.42+19-CA (build 21.0.7+6-LTS)
    OpenJDK 64-Bit Server VM Zulu21.42+19-CA (build 21.0.7+6-LTS, mixed mode, sharing)
  • OS and version (eg uname -a): x86_64 GNU/Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions