Skip to content

Commit 5fa114c

Browse files
committed
Gemini feedback 2
1 parent 54dd78f commit 5fa114c

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

server-common/src/main/java/io/a2a/server/events/EventQueue.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -306,21 +306,19 @@ void childClosing(ChildQueue child, boolean immediate) {
306306
* Called by MainEventBusProcessor after TaskStore persistence.
307307
*/
308308
void distributeToChildren(EventQueueItem item) {
309-
synchronized (children) {
310-
int childCount = children.size();
311-
if (LOGGER.isDebugEnabled()) {
312-
LOGGER.debug("MainQueue[{}]: Distributing event {} to {} children",
313-
taskId, item.getEvent().getClass().getSimpleName(), childCount);
314-
}
315-
children.forEach(child -> {
316-
LOGGER.debug("MainQueue[{}]: Enqueueing event {} to child queue",
317-
taskId, item.getEvent().getClass().getSimpleName());
318-
child.internalEnqueueItem(item);
319-
});
320-
if (LOGGER.isDebugEnabled()) {
321-
LOGGER.debug("MainQueue[{}]: Completed distribution of {} to {} children",
322-
taskId, item.getEvent().getClass().getSimpleName(), childCount);
323-
}
309+
int childCount = children.size();
310+
if (LOGGER.isDebugEnabled()) {
311+
LOGGER.debug("MainQueue[{}]: Distributing event {} to {} children",
312+
taskId, item.getEvent().getClass().getSimpleName(), childCount);
313+
}
314+
children.forEach(child -> {
315+
LOGGER.debug("MainQueue[{}]: Enqueueing event {} to child queue",
316+
taskId, item.getEvent().getClass().getSimpleName());
317+
child.internalEnqueueItem(item);
318+
});
319+
if (LOGGER.isDebugEnabled()) {
320+
LOGGER.debug("MainQueue[{}]: Completed distribution of {} to {} children",
321+
taskId, item.getEvent().getClass().getSimpleName(), childCount);
324322
}
325323
}
326324

server-common/src/main/java/io/a2a/server/events/MainEventBusProcessor.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void setCallback(MainEventBusProcessorCallback callback) {
7878
@PostConstruct
7979
void start() {
8080
processorThread = new Thread(this, "MainEventBusProcessor");
81-
processorThread.setDaemon(false); // Keep JVM alive
81+
processorThread.setDaemon(true); // Allow JVM to exit even if this thread is running
8282
processorThread.start();
8383
LOGGER.info("MainEventBusProcessor started");
8484
}
@@ -98,9 +98,13 @@ void stop() {
9898
if (processorThread != null) {
9999
processorThread.interrupt();
100100
try {
101+
long start = System.currentTimeMillis();
101102
processorThread.join(5000); // Wait up to 5 seconds
103+
long elapsed = System.currentTimeMillis() - start;
104+
LOGGER.info("MainEventBusProcessor thread stopped in {}ms", elapsed);
102105
} catch (InterruptedException e) {
103106
Thread.currentThread().interrupt();
107+
LOGGER.warn("Interrupted while waiting for MainEventBusProcessor thread to stop");
104108
}
105109
}
106110
LOGGER.info("MainEventBusProcessor stopped");

0 commit comments

Comments
 (0)