Skip to content

Commit ea0b91d

Browse files
committed
fix(server): cover direct request handler wiring
Start the main event bus processor from the public request handler constructor and verify the direct manual wiring path.\n\nThis fixes #995
1 parent d58f5a8 commit ea0b91d

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎server-common/src/main/java/org/a2aproject/sdk/server/events/MainEventBusProcessor.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public void setPushNotificationExecutor(java.util.concurrent.Executor executor)
138138
@SuppressWarnings("NullAway.Init")
139139
@PostConstruct
140140
synchronized void start() {
141-
if (processorThread != null) {
141+
if (processorThread != null && processorThread.isAlive()) {
142142
LOGGER.debug("MainEventBusProcessor already started");
143143
return;
144144
}

‎server-common/src/main/java/org/a2aproject/sdk/server/requesthandlers/DefaultRequestHandler.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ public DefaultRequestHandler(AgentExecutor agentExecutor, TaskStore taskStore,
282282
// I am unsure about the correct scope.
283283
// Also reworked to make a Supplier since otherwise the builder gets polluted with wrong tasks
284284
this.requestContextBuilder = () -> new SimpleRequestContextBuilder(taskStore, false);
285+
this.mainEventBusProcessor.ensureStarted();
285286
}
286287

287288
@SuppressWarnings("NullAway.Init")
@@ -309,7 +310,6 @@ public static DefaultRequestHandler create(AgentExecutor agentExecutor, TaskStor
309310
handler.agentCompletionTimeoutSeconds = 5;
310311
handler.consumptionCompletionTimeoutSeconds = 2;
311312
handler.reconciliationTimeoutSeconds = 1;
312-
handler.mainEventBusProcessor.ensureStarted();
313313

314314
return handler;
315315
}

‎server-common/src/test/java/org/a2aproject/sdk/server/requesthandlers/DefaultRequestHandlerTest.java‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ void testInitConfigReadsBlockingTimeouts() {
166166
}
167167

168168
@Test
169-
void testCreateStartsManuallyConstructedMainEventBusProcessor() throws Exception {
169+
void testConstructorStartsManuallyConstructedMainEventBusProcessor() throws Exception {
170170
InMemoryTaskStore manualTaskStore = new InMemoryTaskStore();
171171
PushNotificationConfigStore manualPushConfigStore = new InMemoryPushNotificationConfigStore();
172172
MainEventBus manualMainEventBus = new MainEventBus();
@@ -186,9 +186,12 @@ public void cancel(RequestContext context, AgentEmitter agentEmitter) {
186186
throw new AssertionError("Cancel should not be invoked");
187187
}
188188
};
189-
RequestHandler manualRequestHandler = DefaultRequestHandler.create(
189+
DefaultRequestHandler manualRequestHandler = new DefaultRequestHandler(
190190
manualAgentExecutor, manualTaskStore, manualQueueManager, manualPushConfigStore,
191191
manualProcessor, internalExecutor, internalExecutor);
192+
manualRequestHandler.agentCompletionTimeoutSeconds = 5;
193+
manualRequestHandler.consumptionCompletionTimeoutSeconds = 2;
194+
manualRequestHandler.reconciliationTimeoutSeconds = 1;
192195

193196
EventKind eventKind = manualRequestHandler.onMessageSend(
194197
MessageSendParams.builder().message(MESSAGE).build(), NULL_CONTEXT);

0 commit comments

Comments
 (0)