Skip to content

Commit 982138c

Browse files
authored
fix: add clarifying comment about done callback and consuming order (#154)
# Description Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [x] Follow the [`CONTRIBUTING` Guide](../CONTRIBUTING.md). - [ ] Make your Pull Request title in the <https://www.conventionalcommits.org/> specification. - Important Prefixes for [release-please](https://github.com/googleapis/release-please): - `fix:` which represents bug fixes, and correlates to a [SemVer](https://semver.org/) patch. - `feat:` represents a new feature, and correlates to a SemVer minor. - `feat!:`, or `fix!:`, `refactor!:`, etc., which represent a breaking change (indicated by the `!`) and will result in a SemVer major. - [x] Ensure the tests pass - [x] Appropriate READMEs were updated (if necessary) Fixes #<issue_number_goes_here> 🦕
1 parent fd0cdb7 commit 982138c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sdk-server-common/src/main/java/io/a2a/server/requesthandlers/DefaultRequestHandler.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ public EventKind onMessageSend(MessageSendParams params) throws JSONRPCError {
162162
ResultAggregator.EventTypeAndInterrupt etai = null;
163163
try {
164164
EventConsumer consumer = new EventConsumer(queue);
165+
166+
// This callback must be added before we start consuming. Otherwise,
167+
// any errors thrown by the producerRunnable are not picked up by the consumer
165168
producerRunnable.addDoneCallback(consumer.createAgentRunnableDoneCallback());
166169
etai = resultAggregator.consumeAndBreakOnInterrupt(consumer);
167170

@@ -204,8 +207,9 @@ public Flow.Publisher<StreamingEventKind> onMessageSendStream(MessageSendParams
204207
try {
205208
EventConsumer consumer = new EventConsumer(queue);
206209

210+
// This callback must be added before we start consuming. Otherwise,
211+
// any errors thrown by the producerRunnable are not picked up by the consumer
207212
producerRunnable.addDoneCallback(consumer.createAgentRunnableDoneCallback());
208-
209213
Flow.Publisher<Event> results = resultAggregator.consumeAndEmit(consumer);
210214

211215
Flow.Publisher<Event> eventPublisher =

0 commit comments

Comments
 (0)