Skip to content

Fix busy-spin in OutputStreamPublisher await() - #37657

Open
L00PLeGeNd wants to merge 1 commit into
spring-projects:mainfrom
L00PLeGeNd:fix/37621-outputstream-publisher-busy-spin
Open

L00PLeGeNd wants to merge 1 commit into
spring-projects:mainfrom
L00PLeGeNd:fix/37621-outputstream-publisher-busy-spin

Conversation

@L00PLeGeNd

@L00PLeGeNd L00PLeGeNd commented Nov 7, 2026 •

Copy link
Copy Markdown

Description

Same busy-spin as #37159, but in OutputStreamPublisher.await() (both the spring-core and spring-web copies).

After park() returns without a resume() (interrupt or spurious wakeup), parkedThread still held the writer. Later CAS attempts failed, so the loop neither parked nor exited and burned CPU until more demand arrived or the subscription was cancelled.

Apply the same fix as SubscriberInputStream:

  • park again while the parked-thread reference is still ours
  • on interrupt, restore the flag, clear the reference, and throw InterruptedIOException

Related

Fixes #37621

Checklist

  • Commit message includes Signed-off-by (DCO)
  • Regression tests for interrupt-while-awaiting-demand (core + web)

Same failure mode as spring-projects#37159 in SubscriberInputStream: after interrupt or
spurious wakeup, parkedThread kept the writer reference so the CAS never
parked again and the loop spun. Park while the reference is still ours,
and on interrupt restore the flag, clear the reference, and throw
InterruptedIOException.

Applies to both spring-core and spring-web copies.

Fixes spring-projects#37621

Signed-off-by: Yinghuai Fu <328742512@qq.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 7, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Busy-spin in OutputStreamPublisher.await() when interrupted while awaiting demand

2 participants