You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c257762
Browse filesBrowse the repository at this point in the historyBrowse files
* fix(client): deliver exactly one terminal SSE callback (a2aproject#1170)
The JSON-RPC SSE listeners guarded only onComplete() with a volatile
completed flag, so onError, a parse failure, and post-cancellation
signals could each still reach the error/completion consumer, delivering
more than one terminal callback (including a null completion after an
error or cancellation).
Introduce one shared atomic transition. AbstractSSEEventListener now
owns an AtomicBoolean and a signalTerminal(Throwable) helper that lets
the first caller win via compareAndSet and delivers exactly one outcome
(a non-null failure or a null normal completion); every later signal is
dropped. onError, onComplete and the parse-error path all route through
it. The 0.3 compatibility JSON-RPC listener, which does not share the
base class, mirrors the same AtomicBoolean pattern. REST is left as is
(both native and 0.3 use a no-op completion callback, an API decision).
Tests cover complete-then-error, error-then-complete, repeated
completion, a 32-thread concurrent race, and a final event followed by
completion, asserting exactly one terminal callback in each.
Signal normal completion before auto-closing streams for final events so cancellation cannot report a contradictory terminal outcome. Apply this to the shared listener and the v0.3 JSON-RPC listener.
Verify that an onError callback caused by closing a stream after a final event does not replace the normal completion outcome in native and v0.3 JSON-RPC listeners.
This fixesa2aproject#1170
---------
Signed-off-by: AlgoVoi <chopmob@gmail.com>
Co-authored-by: Kabir Khan <kkhan@redhat.com>
Copy file name to clipboardExpand all lines: client/transport/jsonrpc/src/main/java/org/a2aproject/sdk/client/transport/jsonrpc/sse/SSEEventListener.java
Copy file name to clipboardExpand all lines: client/transport/jsonrpc/src/test/java/org/a2aproject/sdk/client/transport/jsonrpc/sse/SSEEventListenerTest.java
Copy file name to clipboardExpand all lines: client/transport/spi/src/main/java/org/a2aproject/sdk/client/transport/spi/sse/AbstractSSEEventListener.java
Copy file name to clipboardExpand all lines: compat-0.3/client/transport/jsonrpc/src/main/java/org/a2aproject/sdk/compat03/client/transport/jsonrpc/sse/SSEEventListener_v0_3.java
0 commit comments