Skip to content

Commit e2d6011

Browse files
014-codekabir
authored andcommitted
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 a2aproject#995
1 parent 12bb82e commit e2d6011

3 files changed

Lines changed: 7 additions & 3 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
@@ -159,7 +159,7 @@ int pushNotificationChainCount() {
159159
@SuppressWarnings("NullAway.Init")
160160
@PostConstruct
161161
synchronized void start() {
162-
if (processorThread != null) {
162+
if (processorThread != null && processorThread.isAlive()) {
163163
LOGGER.debug("MainEventBusProcessor already started");
164164
return;
165165
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ public DefaultRequestHandler(AgentExecutor agentExecutor, TaskStore taskStore,
326326
// I am unsure about the correct scope.
327327
// Also reworked to make a Supplier since otherwise the builder gets polluted with wrong tasks
328328
this.requestContextBuilder = () -> new SimpleRequestContextBuilder(taskStore, false, null);
329+
this.mainEventBusProcessor.start();
329330
}
330331

331332
@SuppressWarnings("NullAway.Init")

‎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
@@ -187,7 +187,7 @@ void testInitConfigReadsBlockingTimeouts() {
187187
}
188188

189189
@Test
190-
void testCreateStartsManuallyConstructedMainEventBusProcessor() throws Exception {
190+
void testConstructorStartsManuallyConstructedMainEventBusProcessor() throws Exception {
191191
InMemoryTaskStore manualTaskStore = new InMemoryTaskStore();
192192
PushNotificationConfigStore manualPushConfigStore = new InMemoryPushNotificationConfigStore();
193193
MainEventBus manualMainEventBus = new MainEventBus();
@@ -207,9 +207,12 @@ public void cancel(RequestContext context, AgentEmitter agentEmitter) {
207207
throw new AssertionError("Cancel should not be invoked");
208208
}
209209
};
210-
RequestHandler manualRequestHandler = DefaultRequestHandler.create(
210+
DefaultRequestHandler manualRequestHandler = new DefaultRequestHandler(
211211
manualAgentExecutor, manualTaskStore, manualQueueManager, manualPushConfigStore,
212212
manualProcessor, internalExecutor, internalExecutor);
213+
manualRequestHandler.agentCompletionTimeoutSeconds = 5;
214+
manualRequestHandler.consumptionCompletionTimeoutSeconds = 2;
215+
manualRequestHandler.reconciliationTimeoutSeconds = 1;
213216

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

0 commit comments

Comments
 (0)