Skip to content

Commit 46793cf

Browse files
authored
feat: update grpc-java to the newer version; handle introduced StatusException (#488)
# Description Update the [grpc-java](https://github.com/grpc/grpc-java/releases) used to the latest available release - 1.77. It introduces the StatusException on the BlockingClientCall, add adjustments for this case as well. I've run the tests and they all finished successfully: ``` [INFO] --------------------------------[ pom ]--------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for Java SDK A2A Parent 0.4.0.Alpha1-SNAPSHOT: [INFO] [INFO] Java SDK A2A Parent ................................ SUCCESS [ 0.006 s] [INFO] A2A Java SDK - BOM Test Utilities .................. SUCCESS [ 1.071 s] [INFO] Java SDK A2A Common ................................ SUCCESS [ 0.211 s] [INFO] Java SDK A2A Spec .................................. SUCCESS [ 1.999 s] [INFO] Java SDK A2A HTTP Client ........................... SUCCESS [ 1.993 s] [INFO] Java SDK A2A Client Transport: SPI ................. SUCCESS [ 0.777 s] [INFO] Java SDK A2A Client Transport: JSONRPC ............. SUCCESS [ 5.879 s] [INFO] Java SDK A2A Spec: gRPC ............................ SUCCESS [ 1.466 s] [INFO] Java SDK A2A Client Transport: gRPC ................ SUCCESS [ 0.058 s] [INFO] Java SDK A2A Client Transport: JSON+HTTP/REST ...... SUCCESS [ 4.507 s] [INFO] Java SDK A2A Client ................................ SUCCESS [ 5.255 s] [INFO] Java SDK A2A Examples: Hello World ................. SUCCESS [ 0.019 s] [INFO] Java SDK A2A Examples .............................. SUCCESS [ 0.801 s] [INFO] Java SDK A2A Core .................................. SUCCESS [ 16.824 s] [INFO] Java A2A SDK Server Tests Common ................... SUCCESS [ 0.094 s] [INFO] A2A Java SDK - MicroProfile Config Integration ..... SUCCESS [ 5.229 s] [INFO] Java A2A Reference Server: Common .................. SUCCESS [ 0.451 s] [INFO] Java SDK A2A Transport: JSONRPC .................... SUCCESS [ 3.347 s] [INFO] Java A2A Reference Server: JSONRPC ................. SUCCESS [ 31.455 s] [INFO] Java SDK A2A Examples .............................. SUCCESS [ 1.216 s] [INFO] A2A Java SDK :: Extras :: Common ................... SUCCESS [ 0.023 s] [INFO] Java A2A Extras: JPA Database TaskStore ............ SUCCESS [ 15.282 s] [INFO] Java A2A Extras: JPA Database PushNotificationConfigStore SUCCESS [ 11.814 s] [INFO] Java A2A Extras: Replicated Queue Manager Parent ... SUCCESS [ 0.001 s] [INFO] Java A2A Extras: Replicated Queue Manager Core ..... SUCCESS [ 1.550 s] [INFO] Java A2A Extras: Replicated Queue Manager MicroProfile Reactive Messaging SUCCESS [ 2.447 s] [INFO] A2A Java SDK - Cloud Deployment Example Server ..... SUCCESS [ 1.379 s] [INFO] Java A2A Extras: Replicated Queue Manager Tests - Single Instance SUCCESS [ 14.694 s] [INFO] Java A2A Extras: Replicated Queue Manager Tests - Multi Instance Parent SUCCESS [ 0.001 s] [INFO] Java A2A Extras: Replicated Queue Manager Tests - Multi Instance Common SUCCESS [ 0.032 s] [INFO] Java A2A Extras: Replicated Queue Manager Tests - Multi Instance App 1 SUCCESS [ 0.058 s] [INFO] Java A2A Extras: Replicated Queue Manager Tests - Multi Instance App 2 SUCCESS [ 0.058 s] [INFO] Java A2A Extras: Replicated Queue Manager Tests - Multi Instance Tests SUCCESS [01:00 min] [INFO] Java SDK A2A Transport: gRPC ....................... SUCCESS [ 2.817 s] [INFO] Java A2A Reference Server: gRPC .................... SUCCESS [ 26.423 s] [INFO] Java SDK A2A Transport: JSON+HTTP/REST ............. SUCCESS [ 1.915 s] [INFO] Java A2A Reference Server: JSON+HTTP/REST .......... SUCCESS [ 29.314 s] [INFO] Java SDK A2A TCK Server ............................ SUCCESS [ 1.405 s] [INFO] A2A Java SDK - BOM ................................. SUCCESS [ 0.015 s] [INFO] A2A Java SDK - Extras BOM .......................... SUCCESS [ 0.001 s] [INFO] A2A Java SDK - Reference Implementations BOM ....... SUCCESS [ 0.000 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 04:16 min [INFO] Finished at: 2025-11-26T14:02:51Z [INFO] ------------------------------------------------------------------------ ``` 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). - [X] 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 c154104 commit 46793cf

File tree

4 files changed

+29
-31
lines changed

4 files changed

+29
-31
lines changed

client/transport/grpc/src/main/java/io/a2a/client/transport/grpc/GrpcErrorMapper.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@
1313
import io.a2a.spec.TaskNotFoundError;
1414
import io.a2a.spec.UnsupportedOperationError;
1515
import io.grpc.Status;
16-
import io.grpc.StatusRuntimeException;
1716

1817
/**
19-
* Utility class to map gRPC StatusRuntimeException to appropriate A2A error types
18+
* Utility class to map gRPC exceptions to appropriate A2A error types
2019
*/
2120
public class GrpcErrorMapper {
2221

23-
public static A2AClientException mapGrpcError(StatusRuntimeException e) {
22+
public static A2AClientException mapGrpcError(Throwable e) {
2423
return mapGrpcError(e, "gRPC error: ");
2524
}
2625

27-
public static A2AClientException mapGrpcError(StatusRuntimeException e, String errorPrefix) {
28-
Status.Code code = e.getStatus().getCode();
29-
String description = e.getStatus().getDescription();
26+
public static A2AClientException mapGrpcError(Throwable e, String errorPrefix) {
27+
Status status = Status.fromThrowable(e);
28+
Status.Code code = status.getCode();
29+
String description = status.getDescription();
3030

3131
// Extract the actual error type from the description if possible
3232
// (using description because the same code can map to multiple errors -

client/transport/grpc/src/main/java/io/a2a/client/transport/grpc/GrpcTransport.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import io.a2a.spec.TaskQueryParams;
4545
import io.grpc.Channel;
4646
import io.grpc.Metadata;
47+
import io.grpc.StatusException;
4748
import io.grpc.StatusRuntimeException;
4849
import io.grpc.stub.MetadataUtils;
4950
import io.grpc.stub.StreamObserver;
@@ -93,7 +94,7 @@ public EventKind sendMessage(MessageSendParams request, @Nullable ClientCallCont
9394
} else {
9495
throw new A2AClientException("Server response did not contain a message or task");
9596
}
96-
} catch (StatusRuntimeException e) {
97+
} catch (StatusRuntimeException | StatusException e) {
9798
throw GrpcErrorMapper.mapGrpcError(e, "Failed to send message: ");
9899
}
99100
}
@@ -130,7 +131,7 @@ public Task getTask(TaskQueryParams request, @Nullable ClientCallContext context
130131
try {
131132
A2AServiceBlockingV2Stub stubWithMetadata = createBlockingStubWithMetadata(context, payloadAndHeaders);
132133
return FromProto.task(stubWithMetadata.getTask(getTaskRequest));
133-
} catch (StatusRuntimeException e) {
134+
} catch (StatusRuntimeException | StatusException e) {
134135
throw GrpcErrorMapper.mapGrpcError(e, "Failed to get task: ");
135136
}
136137
}
@@ -148,7 +149,7 @@ public Task cancelTask(TaskIdParams request, @Nullable ClientCallContext context
148149
try {
149150
A2AServiceBlockingV2Stub stubWithMetadata = createBlockingStubWithMetadata(context, payloadAndHeaders);
150151
return FromProto.task(stubWithMetadata.cancelTask(cancelTaskRequest));
151-
} catch (StatusRuntimeException e) {
152+
} catch (StatusRuntimeException | StatusException e) {
152153
throw GrpcErrorMapper.mapGrpcError(e, "Failed to cancel task: ");
153154
}
154155
}
@@ -195,7 +196,7 @@ public ListTasksResult listTasks(ListTasksParams request, @Nullable ClientCallCo
195196
grpcResponse.getTasksCount(),
196197
grpcResponse.getNextPageToken().isEmpty() ? null : grpcResponse.getNextPageToken()
197198
);
198-
} catch (StatusRuntimeException e) {
199+
} catch (StatusRuntimeException | StatusException e) {
199200
throw GrpcErrorMapper.mapGrpcError(e, "Failed to list tasks: ");
200201
}
201202
}
@@ -237,7 +238,7 @@ public TaskPushNotificationConfig getTaskPushNotificationConfiguration(
237238
try {
238239
A2AServiceBlockingV2Stub stubWithMetadata = createBlockingStubWithMetadata(context, payloadAndHeaders);
239240
return FromProto.taskPushNotificationConfig(stubWithMetadata.getTaskPushNotificationConfig(grpcRequest));
240-
} catch (StatusRuntimeException e) {
241+
} catch (StatusRuntimeException | StatusException e) {
241242
throw GrpcErrorMapper.mapGrpcError(e, "Failed to get task push notification config: ");
242243
}
243244
}
@@ -259,7 +260,7 @@ public List<TaskPushNotificationConfig> listTaskPushNotificationConfigurations(
259260
return stubWithMetadata.listTaskPushNotificationConfig(grpcRequest).getConfigsList().stream()
260261
.map(FromProto::taskPushNotificationConfig)
261262
.collect(Collectors.toList());
262-
} catch (StatusRuntimeException e) {
263+
} catch (StatusRuntimeException | StatusException e) {
263264
throw GrpcErrorMapper.mapGrpcError(e, "Failed to list task push notification config: ");
264265
}
265266
}
@@ -278,7 +279,7 @@ public void deleteTaskPushNotificationConfigurations(DeleteTaskPushNotificationC
278279
try {
279280
A2AServiceBlockingV2Stub stubWithMetadata = createBlockingStubWithMetadata(context, payloadAndHeaders);
280281
stubWithMetadata.deleteTaskPushNotificationConfig(grpcRequest);
281-
} catch (StatusRuntimeException e) {
282+
} catch (StatusRuntimeException | StatusException e) {
282283
throw GrpcErrorMapper.mapGrpcError(e, "Failed to delete task push notification config: ");
283284
}
284285
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939

4040
<properties>
41-
<grpc.version>1.73.0</grpc.version>
41+
<grpc.version>1.77.0</grpc.version>
4242
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4343
<maven-clean-plugin.version>3.5.0</maven-clean-plugin.version>
4444
<maven-compiler-plugin.version>3.14.1</maven-compiler-plugin.version>

spec-grpc/src/main/java/io/a2a/grpc/A2AServiceGrpc.java

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
* A2AService defines the operations of the A2A protocol.
88
* </pre>
99
*/
10-
@javax.annotation.Generated(
11-
value = "by gRPC proto compiler (version 1.73.0)",
12-
comments = "Source: a2a.proto")
1310
@io.grpc.stub.annotations.GrpcGenerated
1411
public final class A2AServiceGrpc {
1512

@@ -717,8 +714,8 @@ protected A2AServiceBlockingV2Stub build(
717714
* Send a message to the agent.
718715
* </pre>
719716
*/
720-
public io.a2a.grpc.SendMessageResponse sendMessage(io.a2a.grpc.SendMessageRequest request) {
721-
return io.grpc.stub.ClientCalls.blockingUnaryCall(
717+
public io.a2a.grpc.SendMessageResponse sendMessage(io.a2a.grpc.SendMessageRequest request) throws io.grpc.StatusException {
718+
return io.grpc.stub.ClientCalls.blockingV2UnaryCall(
722719
getChannel(), getSendMessageMethod(), getCallOptions(), request);
723720
}
724721

@@ -739,8 +736,8 @@ public io.a2a.grpc.SendMessageResponse sendMessage(io.a2a.grpc.SendMessageReques
739736
* Get the current state of a task from the agent.
740737
* </pre>
741738
*/
742-
public io.a2a.grpc.Task getTask(io.a2a.grpc.GetTaskRequest request) {
743-
return io.grpc.stub.ClientCalls.blockingUnaryCall(
739+
public io.a2a.grpc.Task getTask(io.a2a.grpc.GetTaskRequest request) throws io.grpc.StatusException {
740+
return io.grpc.stub.ClientCalls.blockingV2UnaryCall(
744741
getChannel(), getGetTaskMethod(), getCallOptions(), request);
745742
}
746743

@@ -749,8 +746,8 @@ public io.a2a.grpc.Task getTask(io.a2a.grpc.GetTaskRequest request) {
749746
* List tasks with optional filtering and pagination.
750747
* </pre>
751748
*/
752-
public io.a2a.grpc.ListTasksResponse listTasks(io.a2a.grpc.ListTasksRequest request) {
753-
return io.grpc.stub.ClientCalls.blockingUnaryCall(
749+
public io.a2a.grpc.ListTasksResponse listTasks(io.a2a.grpc.ListTasksRequest request) throws io.grpc.StatusException {
750+
return io.grpc.stub.ClientCalls.blockingV2UnaryCall(
754751
getChannel(), getListTasksMethod(), getCallOptions(), request);
755752
}
756753

@@ -759,8 +756,8 @@ public io.a2a.grpc.ListTasksResponse listTasks(io.a2a.grpc.ListTasksRequest requ
759756
* Cancel a task.
760757
* </pre>
761758
*/
762-
public io.a2a.grpc.Task cancelTask(io.a2a.grpc.CancelTaskRequest request) {
763-
return io.grpc.stub.ClientCalls.blockingUnaryCall(
759+
public io.a2a.grpc.Task cancelTask(io.a2a.grpc.CancelTaskRequest request) throws io.grpc.StatusException {
760+
return io.grpc.stub.ClientCalls.blockingV2UnaryCall(
764761
getChannel(), getCancelTaskMethod(), getCallOptions(), request);
765762
}
766763

@@ -792,8 +789,8 @@ public io.a2a.grpc.TaskPushNotificationConfig setTaskPushNotificationConfig(io.a
792789
* Get a push notification config for a task.
793790
* </pre>
794791
*/
795-
public io.a2a.grpc.TaskPushNotificationConfig getTaskPushNotificationConfig(io.a2a.grpc.GetTaskPushNotificationConfigRequest request) {
796-
return io.grpc.stub.ClientCalls.blockingUnaryCall(
792+
public io.a2a.grpc.TaskPushNotificationConfig getTaskPushNotificationConfig(io.a2a.grpc.GetTaskPushNotificationConfigRequest request) throws io.grpc.StatusException {
793+
return io.grpc.stub.ClientCalls.blockingV2UnaryCall(
797794
getChannel(), getGetTaskPushNotificationConfigMethod(), getCallOptions(), request);
798795
}
799796

@@ -802,8 +799,8 @@ public io.a2a.grpc.TaskPushNotificationConfig getTaskPushNotificationConfig(io.a
802799
* Get a list of push notifications configured for a task.
803800
* </pre>
804801
*/
805-
public io.a2a.grpc.ListTaskPushNotificationConfigResponse listTaskPushNotificationConfig(io.a2a.grpc.ListTaskPushNotificationConfigRequest request) {
806-
return io.grpc.stub.ClientCalls.blockingUnaryCall(
802+
public io.a2a.grpc.ListTaskPushNotificationConfigResponse listTaskPushNotificationConfig(io.a2a.grpc.ListTaskPushNotificationConfigRequest request) throws io.grpc.StatusException {
803+
return io.grpc.stub.ClientCalls.blockingV2UnaryCall(
807804
getChannel(), getListTaskPushNotificationConfigMethod(), getCallOptions(), request);
808805
}
809806

@@ -822,8 +819,8 @@ public io.a2a.grpc.AgentCard getExtendedAgentCard(io.a2a.grpc.GetExtendedAgentCa
822819
* Delete a push notification config for a task.
823820
* </pre>
824821
*/
825-
public com.google.protobuf.Empty deleteTaskPushNotificationConfig(io.a2a.grpc.DeleteTaskPushNotificationConfigRequest request) {
826-
return io.grpc.stub.ClientCalls.blockingUnaryCall(
822+
public com.google.protobuf.Empty deleteTaskPushNotificationConfig(io.a2a.grpc.DeleteTaskPushNotificationConfigRequest request) throws io.grpc.StatusException {
823+
return io.grpc.stub.ClientCalls.blockingV2UnaryCall(
827824
getChannel(), getDeleteTaskPushNotificationConfigMethod(), getCallOptions(), request);
828825
}
829826
}

0 commit comments

Comments
 (0)