Skip to content

Commit fb330b4

Browse files
committed
Upgrade to latest a2a-java and get the tests passing
1 parent 99e8a31 commit fb330b4

File tree

6 files changed

+42
-10
lines changed

6 files changed

+42
-10
lines changed

impl/grpc/src/main/java/org/wildfly/extras/a2a/server/apps/grpc/GrpcBeanInitializer.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.wildfly.extras.a2a.server.apps.grpc;
22

3+
import java.util.concurrent.Executor;
4+
35
import jakarta.annotation.PreDestroy;
46
import jakarta.enterprise.context.ApplicationScoped;
57
import jakarta.enterprise.context.Initialized;
@@ -9,6 +11,7 @@
911

1012
import io.a2a.server.PublicAgentCard;
1113
import io.a2a.server.requesthandlers.RequestHandler;
14+
import io.a2a.server.util.async.Internal;
1215
import io.a2a.spec.AgentCard;
1316
import io.a2a.transport.grpc.handler.CallContextFactory;
1417

@@ -32,6 +35,10 @@ public class GrpcBeanInitializer {
3235
@Inject
3336
Instance<CallContextFactory> callContextFactory;
3437

38+
@Inject
39+
@Internal
40+
Executor executor;
41+
3542
/**
3643
* Observes the application startup event to eagerly initialize the gRPC cache.
3744
*/
@@ -40,8 +47,8 @@ public void onStartup(@Observes @Initialized(ApplicationScoped.class) Object ini
4047
try {
4148
// Cache CDI beans for gRPC threads to use since CDI is not available on those threads
4249
CallContextFactory ccf = callContextFactory.isUnsatisfied() ? null : callContextFactory.get();
43-
WildFlyGrpcHandler.setStaticBeans(agentCard, requestHandler, ccf);
44-
System.out.println("*** GrpcBeanInitializer successfully cached beans: agentCard=" + agentCard + ", requestHandler=" + requestHandler + ", callContextFactory=" + ccf + " ***");
50+
WildFlyGrpcHandler.setStaticBeans(agentCard, requestHandler, ccf, executor);
51+
System.out.println("*** GrpcBeanInitializer successfully cached beans: agentCard=" + agentCard + ", requestHandler=" + requestHandler + ", callContextFactory=" + ccf + ", executor=" + executor + " ***");
4552
} catch (Exception e) {
4653
System.err.println("*** GrpcBeanInitializer.onStartup() failed: " + e.getMessage());
4754
e.printStackTrace();
@@ -50,6 +57,6 @@ public void onStartup(@Observes @Initialized(ApplicationScoped.class) Object ini
5057

5158
@PreDestroy
5259
public void cleanup() {
53-
WildFlyGrpcHandler.setStaticBeans(null, null, null);
60+
WildFlyGrpcHandler.setStaticBeans(null, null, null, null);
5461
}
5562
}

impl/grpc/src/main/java/org/wildfly/extras/a2a/server/apps/grpc/WildFlyGrpcHandler.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ public class WildFlyGrpcHandler extends GrpcHandler {
2525
private static volatile AgentCard staticAgentCard;
2626
private static volatile RequestHandler staticRequestHandler;
2727
private static volatile CallContextFactory staticCallContextFactory;
28-
29-
@Inject
30-
@Internal
31-
protected Executor executor;
28+
private static volatile Executor staticExecutor;
3229

3330
public WildFlyGrpcHandler() {
3431
// Default constructor - the only one used by WildFly gRPC subsystem
@@ -38,10 +35,11 @@ public WildFlyGrpcHandler() {
3835
* Called by GrpcBeanInitializer during CDI initialization to cache beans
3936
* for use by gRPC threads where CDI is not available.
4037
*/
41-
static void setStaticBeans(AgentCard agentCard, RequestHandler requestHandler, CallContextFactory callContextFactory) {
38+
static void setStaticBeans(AgentCard agentCard, RequestHandler requestHandler, CallContextFactory callContextFactory, Executor executor) {
4239
staticAgentCard = agentCard;
4340
staticRequestHandler = requestHandler;
4441
staticCallContextFactory = callContextFactory;
42+
staticExecutor = executor;
4543
}
4644

4745
@Override
@@ -67,6 +65,9 @@ protected CallContextFactory getCallContextFactory() {
6765

6866
@Override
6967
protected Executor getExecutor() {
70-
return executor;
68+
if (staticExecutor == null) {
69+
throw new RuntimeException("Executor not available. ApplicationStartup may not have run yet.");
70+
}
71+
return staticExecutor;
7172
}
7273
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<properties>
4646
<jboss.home>${project.build.directory}${file.separator}wildfly</jboss.home>
4747
<version.wildfly>38.0.0.Final</version.wildfly>
48-
<version.sdk>0.3.0.Final</version.sdk>
48+
<version.sdk>0.3.1.Beta1</version.sdk>
4949
<!-- This needs to be same version as used by the sdk -->
5050
<version.mutiny-zero>1.1.1</version.mutiny-zero>
5151
<!-- gRPC version matching the a2a-java-sdk -->

tests/grpc/src/test/java/org/wildfly/extras/a2a/server/grpc/wildfly/A2ATestResource.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ public Response getStreamingSubscribedCount() {
105105
return Response.ok(String.valueOf(streamingSubscribedCount.get()), TEXT_PLAIN).build();
106106
}
107107

108+
@GET
109+
@Path("/queue/childCount/{taskId}")
110+
@Produces(TEXT_PLAIN)
111+
public Response getChildQueueCount(@PathParam("taskId") String taskId) {
112+
int count = testUtilsBean.getChildQueueCount(taskId);
113+
return Response.ok(String.valueOf(count), TEXT_PLAIN).build();
114+
}
115+
108116
@DELETE
109117
@Path("/task/{taskId}/config/{configId}")
110118
public Response deleteTaskPushNotificationConfig(@PathParam("taskId") String taskId, @PathParam("configId") String configId) {

tests/jsonrpc/src/test/java/org/wildfly/extras/a2a/test/server/apps/jakarta/A2ATestResource.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ public Response getStreamingSubscribedCount() {
107107
return Response.ok(String.valueOf(streamingSubscribedCount.get()), TEXT_PLAIN).build();
108108
}
109109

110+
@GET
111+
@Path("/queue/childCount/{taskId}")
112+
@Produces(TEXT_PLAIN)
113+
public Response getChildQueueCount(@PathParam("taskId") String taskId) {
114+
int count = testUtilsBean.getChildQueueCount(taskId);
115+
return Response.ok(String.valueOf(count), TEXT_PLAIN).build();
116+
}
117+
110118
@DELETE
111119
@Path("/task/{taskId}/config/{configId}")
112120
public Response deleteTaskPushNotificationConfig(@PathParam("taskId") String taskId, @PathParam("configId") String configId) {

tests/rest/src/test/java/org/wildfly/extras/a2a/test/server/apps/rest/A2ATestResource.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ public Response getStreamingSubscribedCount() {
107107
return Response.ok(String.valueOf(streamingSubscribedCount.get()), TEXT_PLAIN).build();
108108
}
109109

110+
@GET
111+
@Path("/queue/childCount/{taskId}")
112+
@Produces(TEXT_PLAIN)
113+
public Response getChildQueueCount(@PathParam("taskId") String taskId) {
114+
int count = testUtilsBean.getChildQueueCount(taskId);
115+
return Response.ok(String.valueOf(count), TEXT_PLAIN).build();
116+
}
117+
110118
@DELETE
111119
@Path("/task/{taskId}/config/{configId}")
112120
public Response deleteTaskPushNotificationConfig(@PathParam("taskId") String taskId, @PathParam("configId") String configId) {

0 commit comments

Comments
 (0)