Skip to content

FR: AsyncSession.isClosed() #805

@vorburger

Description

@vorburger

Is your feature request related to a problem? Please describe.

IMHO it would be useful for class AsyncSession to have an isClosed() kind of method.

This is because the async session doesn't just get closed by the user when invoking close() but can apparently also get closed by from server when its done ("Live session closed with code: 1000 and reason:").

To avoid the following, it would be useful if an application could check if it's been closed:

[ForkJoinPool.commonPool-worker-2] ERROR dev.enola.common.concurrent.Async - Async error for resource: GoogleLive sendRealtimeInput()
java.util.concurrent.CompletionException: org.java_websocket.exceptions.WebsocketNotConnectedException
        at java.base/java.util.concurrent.CompletableFuture.wrapInCompletionException(CompletableFuture.java:323)
        at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:359)
        at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:364)
        at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1828)
        at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1817)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:511)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1450)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2019)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)
Caused by: org.java_websocket.exceptions.WebsocketNotConnectedException
        at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:669)
        at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:645)
        at org.java_websocket.client.WebSocketClient.send(WebSocketClient.java:445)
        at com.google.genai.AsyncSession.lambda$send$0(AsyncSession.java:110)
        at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1825)
        ... 5 more

Metadata

Metadata

Assignees

Labels

priority: p3Desirable enhancement or fix. May not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions