test(showcase): Add gRPC and HttpJson Showcase ITs to verify Error Details - #13928
test(showcase): Add gRPC and HttpJson Showcase ITs to verify Error Details#13928nnicolee wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new integration test class, ITErrorDetails.java, to verify that standard and custom error details are correctly parsed and unpacked from ApiException for both gRPC and HTTP/JSON clients. The review feedback highlights two main areas for improvement: ensuring exception-safe resource cleanup in destroyClients() to prevent potential resource leaks if one of the clients fails to close, and avoiding the use of fully qualified class names when there are no naming conflicts to improve code readability.
f2ca894 to
dbe16db
Compare
|
Lint issue looks external: Hmm, maybe we try and update the branch. Maybe got fixed in main |
…est/showcase-errordetails
…ogle-cloud-java into test/showcase-errordetails
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new integration test class, ITErrorDetails.java, to verify that standard and custom error details are correctly propagated and deserialized over both gRPC and HTTP/JSON transports. The feedback suggests improving the @AfterAll teardown method to ensure exception-safe cleanup of the clients in reverse order of creation (LIFO) and to include null checks to prevent potential NullPointerExceptions.
| @AfterAll | ||
| static void destroyClients() throws InterruptedException { | ||
| grpcClient.close(); | ||
| httpjsonClient.close(); | ||
|
|
||
| grpcClient.awaitTermination(TestClientInitializer.AWAIT_TERMINATION_SECONDS, TimeUnit.SECONDS); | ||
| httpjsonClient.awaitTermination( | ||
| TestClientInitializer.AWAIT_TERMINATION_SECONDS, TimeUnit.SECONDS); | ||
| } |
There was a problem hiding this comment.
When managing multiple closeable resources, they should be closed in the reverse order of their creation (LIFO) to prevent resource leaks. Additionally, the closing and termination process should be exception-safe so that a failure in closing or awaiting one client does not prevent the other from being properly cleaned up. Also, adding null checks prevents potential NullPointerExceptions if client initialization fails in @BeforeAll.
@AfterAll
static void destroyClients() throws InterruptedException {
try {
if (httpjsonClient != null) {
httpjsonClient.close();
}
} finally {
if (grpcClient != null) {
grpcClient.close();
}
}
try {
if (httpjsonClient != null) {
httpjsonClient.awaitTermination(
TestClientInitializer.AWAIT_TERMINATION_SECONDS, TimeUnit.SECONDS);
}
} finally {
if (grpcClient != null) {
grpcClient.awaitTermination(
TestClientInitializer.AWAIT_TERMINATION_SECONDS, TimeUnit.SECONDS);
}
}
}References
- When managing a collection of closeable resources (e.g., scopes), ensure they are closed in the reverse order of their creation (LIFO). The implementation must be exception-safe to prevent resource leaks, meaning all opened resources should be closed even if exceptions occur during their creation or closing.
- When using lazily initialized resources (such as ExecutorService), ensure that teardown or close methods perform explicit null checks before invoking methods on them to prevent NullPointerException.
Description
This PR introduces E2E integration test coverage for standard and custom error details using the
FailEchoWithDetailsRPC in Showcase, validating the exception propagation and deserialization pipeline across both gRPC and HTTP/JSON transports.Key Changes
ErrorInfo,RetryInfo,DebugInfo,QuotaFailure,PreconditionFailure,BadRequest,RequestInfo,ResourceInfo,Help,LocalizedMessage).PoetryError) are successfully unpacked and mapped into the client-sideErrorDetails.ABORTED) propagates correctly.PoetryError) in JSON status payloads.