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 aa44e3f
Browse filesBrowse the repository at this point in the historyBrowse files
Mark Pollack
committed
Lock the SSE outbound stream on a private object
SseOutboundStream guarded its mailbox and subscriber with its own monitor
(synchronized methods, and synchronized (SseOutboundStream.this) in the
subscriber's drain). Any code holding the stream could take that monitor and
stall the container's write callbacks. A private final lock keeps the same
serialisation without exposing it. SpotBugs reports the old shape as
USO_UNSAFE_OBJECT_SYNCHRONIZATION (rank 7).
Copy file name to clipboardExpand all lines: acp-streamable-http-jetty/src/main/java/com/agentclientprotocol/sdk/agent/transport/SseOutboundStream.java
+87-71Lines changed: 87 additions & 71 deletions
Original file line number
Diff line number
Diff line change
@@ -32,8 +32,8 @@
32
32
* backpressure, a new GET took the stream over, or the container reported an error on
33
33
* another thread) its unconfirmed events go back to the front of the queue in order, and
34
34
* the next subscriber continues from there. All state changes happen under this stream's
35
-
* monitor, including the container's asynchronous callbacks, so a reconnect racing the old
36
-
* subscriber's close is serialised.
35
+
* private lock, including the container's asynchronous callbacks, so a reconnect racing
36
+
* the old subscriber's close is serialised.
37
37
* </p>
38
38
*
39
39
* <p>
@@ -62,17 +62,23 @@ final class SseOutboundStream {
62
62
63
63
privatestaticfinalbyte[] NO_BYTES = newbyte[0];
64
64
65
+
/**
66
+
* Guards all state of this stream and its subscriber. Private, not this stream's own
67
+
* monitor, so no other code can take it and stall the container's write callbacks.
68
+
*/
69
+
privatefinalObjectlock = newObject();
70
+
65
71
privatefinalintmailboxCapacity;
66
72
67
73
privatefinalintmaxPendingSseEvents;
68
74
69
-
/** Events not yet written to any subscriber, oldest first. Guarded by {@code this}. */
75
+
/** Events not yet written to any subscriber, oldest first. Guarded by {@code lock}. */
0 commit comments