Skip to content

[BUG] azure-core-amqp: ActiveClientTokenManager interrupts an in-progress token refresh ("IO Sink was interrupted before reactor closed") #50922

Open

Description

@liadl-securitas

Describe the bug
ActiveClientTokenManager schedules refreshes with switchOnNext(durationSource.map(Flux::interval)). The next
refresh duration is emitted from the subscriber of the current refresh (on the CBS reply / reactor thread), possibly
while the current interval tick is still running. switchOnNext cancels the running interval, and cancelling a periodic
task on Schedulers.parallel() calls Future.cancel(true), interrupting the thread performing the refresh. If that
thread is writing to the reactor's IO pipe (ReactorDispatcher.signalWorkQueue), the write fails with
ClosedByInterruptException, the pipe is closed and the whole connection is reset.

Exception or Stack Trace

java.nio.channels.ClosedByInterruptException
    at java.base/java.nio.channels.spi.AbstractInterruptibleChannel.end(...)
    at java.base/sun.nio.ch.SinkChannelImpl.write(...)
    at com.azure.core.amqp.implementation.ReactorDispatcher.signalWorkQueue(...)
...
IO Sink was interrupted before reactor closed

Expected behavior
Scheduling the next token refresh never interrupts work of the current one.

To Reproduce
Long-running producer with token-based auth; intermittent connection resets around token refresh. Deterministic unit
repro: see ActiveClientTokenManagerTest in the linked PR.

Setup

  • Java 17, azure-core-amqp 2.12.1 (same code on main as of 2026-10-21)

Activity

  1. github-actions commented on Oct 22, 2026

    @github-actions
    Contributor

    🎯 Agentic Issue Triage

    Summary: ActiveClientTokenManager in azure-core-amqp uses switchOnNext over Flux::interval, so scheduling the next refresh can cancel and interrupt the in-progress refresh. This can cause ClosedByInterruptException in ReactorDispatcher.signalWorkQueue and a connection reset.

    📋 Issue Details

    Package: com.azure:azure-core-amqp 2.12.1
    Affected API: ActiveClientTokenManager (token refresh scheduling), ReactorDispatcher.signalWorkQueue
    Scenarios:

    • Long-running producer with token-based auth sees intermittent connection resets around token refresh

    Root ask: Scheduling the next refresh must not interrupt the current one (the author references a linked PR with a unit test).

    🔎 Debugging / Reproduction Notes

    The cause is plausible: cancelling a periodic task on Schedulers.parallel() interrupts its thread.

    Suggested investigation steps:

    1. Review ActiveClientTokenManager scheduling and the switchOnNext usage.
    2. Run the ActiveClientTokenManagerTest repro from the linked PR.
    3. Check whether the next refresh can be scheduled without cancelling the in-flight one (for example switchOnNextDelayError, or publishOn/subscribeOn with non-interrupting cancellation).
    🏷️ Label Confidence
    • Category: Client — SDK code behavior bug.
    • Service: Azure.Core.AMQP — the package is azure-core-amqp.
    • Confidence: High — a single package is named and there is no ambiguity.
    👥 Owner Routing
    • Matched CODEOWNERS entry: # ServiceLabel: %Azure.Core.AMQP (line 68) — the service label matches.
    • AzureSdkOwners: @conniey
    • ServiceOwners: none listed
    • Routing action: assigned conniey and added needs-team-attention (external author).
    • Scan notes: %Mgmt (line 945) did not match because the issue is not Mgmt.

    Generated by Agentic Triage for #50922 · auto · 14 AIC · ⊞ 16.3K · ◷

  2. github-actions commented on Oct 22, 2026

    @github-actions
    Contributor

    Thank you for your feedback. Tagging and routing to the team member(s) best able to assist.

    Generated by Agentic Triage for #50922 · auto · 14 AIC · ⊞ 16.3K · ◷

  3. added
    questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
    ClientThis issue points to a problem in the data-plane of the library.
    customer-reportedIssues that are reported by GitHub users external to the Azure organization.
    needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK team
    on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Azure.Core.AMQPazure-core-amqpClientThis issue points to a problem in the data-plane of the library.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions