bug fix for multimodal-dialog agent and add parameter speaker_id in asr result #240
bug fix for multimodal-dialog agent and add parameter speaker_id in asr result #240songguocola wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces graceful shutdown and force-close mechanisms to prevent deadlocks and ensure proper resource cleanup in MultiModalDialog and OkHttpWebSocketClient. It also refactors the streaming request logic in OkHttpWebSocketClient to reduce duplication in its subclasses, and adds a speaker_id field to Sentence. The review feedback highlights two important issues: first, the closed flag in MultiModalDialog needs to be reset to false when start() is called to support restarts; second, the responseEmitter field in OkHttpWebSocketClient should be marked as volatile to prevent potential thread visibility issues and data races.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| BackpressureStrategy.BUFFER); | ||
|
|
||
| stopLatch = new AtomicReference<>(new CountDownLatch(1)); // Initializes stop signal latch | ||
| stopLatch.set(new CountDownLatch(1)); // Initializes stop signal latch |
There was a problem hiding this comment.
If the MultiModalDialog is restarted by calling start() again after being closed, the closed flag remains true. As a result, any subsequent call to close() will return immediately due to the closed.compareAndSet(false, true) check, preventing the new session from being properly closed or cancelled. Resetting closed to false in start() ensures that the idempotent close guard works correctly across multiple sessions of the same dialog instance.
| stopLatch.set(new CountDownLatch(1)); // Initializes stop signal latch | |
| closed.set(false); | |
| stopLatch.set(new CountDownLatch(1)); // Initializes stop signal latch |
| if (responseEmitter != null && !responseEmitter.isCancelled()) { | ||
| responseEmitter.onError(ex); | ||
| } |
There was a problem hiding this comment.
The responseEmitter field is accessed and modified across multiple threads (e.g., the subscribing thread, the async stream request thread, and the WebSocket callback threads). To ensure proper thread visibility and prevent potential data races when checking responseEmitter != null and !responseEmitter.isCancelled(), the responseEmitter field should be declared as volatile.
No description provided.