Skip to content

[Java] Calls on a closed stream throw a retryable ZerobusException #1225

Backlog

Description

Problem

BaseZerobusStream.ensureOpen() throws new ZerobusException("Stream is closed") in two cases: after close() freed the native handle, and when the native stream is already closed (for example after a terminal failure). ZerobusException is the retryable class, so a caller that retries retryable errors with backoff retries a closed stream forever.

The Rust core reports the same condition as InvalidStateError, which is not retryable. A Java call that reaches the native layer during a close also gets NonRetriableException, so the error class a caller sees depends on timing.

Where: java/src/main/java/com/databricks/zerobus/BaseZerobusStream.java, ensureOpen() (both throw new ZerobusException("Stream is closed") lines).

Proposed fix

Throw NonRetriableException("Stream is closed") in both cases, and say in the Javadoc and the README that a call on a closed stream is not retryable. Multiplexed streams do the same (#1195).

Compatibility

NonRetriableException extends ZerobusException, so catch (ZerobusException e) still catches it. Code that retries on the exact class stops retrying a closed stream, which is the intended change; it needs a changelog entry under Bug Fixes.

Activity

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

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