Skip to content

Connection#close throws InterruptedException #1588

@MFAshby

Description

@MFAshby

Observed behavior

The following code produces a compiler warning (with openjdk 25)

    try (Connection connection = Nats.connect(options)) {
        // Do stuff with the connection here
    }

warning message:

auto-closeable resource io.nats.client.Connection has a member method close() that could throw InterruptedException

The documentation for close() strongly advises not to throw InterruptedException from the close() method.

Expected behavior

No compiler warning should be emitted; the close() method should avoid throwing InterruptedException

Server and client version

jnats version 2.21.1

Host environment

n/a, this is a warning at compile time that code may have unexpected runtime effects if an InterruptedException is thrown and swallowed by autocloseable.

Steps to reproduce

See "Observed behaviour"

Metadata

Metadata

Assignees

No one assigned

    Labels

    defectSuspected defect such as a bug or regression

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions