Skip to content

Commit ddabb38

Browse files
committed
test(datastore): use specific exception matching by name in E2E tests
Use ignoreExceptionsMatching with a helper that checks exception class names as strings. This avoids classloader compatibility issues that might prevent ignoreExceptionsInstanceOf from matching correctly, while still keeping the ignored exceptions list specific. TAG=agy CONV=c8697e3d-c06b-4d5b-86e9-f8950e4298fd
1 parent 63676b5 commit ddabb38

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITE2ETracingTest.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ protected void fetchAndValidateTrace(
461461
await()
462462
.atMost(Duration.ofMillis((long) GET_TRACE_RETRY_COUNT * GET_TRACE_RETRY_BACKOFF_MILLIS))
463463
.pollInterval(Duration.ofMillis(GET_TRACE_RETRY_BACKOFF_MILLIS))
464-
.ignoreExceptions()
464+
.ignoreExceptionsMatching(ITE2ETracingTest::isIgnoredException)
465465
.until(
466466
() -> {
467467
retrievedTrace = traceClient.getTrace(projectId, traceId);
@@ -541,7 +541,7 @@ public void traceContainerTest() throws Exception {
541541
await()
542542
.atMost(Duration.ofMillis((long) GET_TRACE_RETRY_COUNT * GET_TRACE_RETRY_BACKOFF_MILLIS))
543543
.pollInterval(Duration.ofMillis(GET_TRACE_RETRY_BACKOFF_MILLIS))
544-
.ignoreExceptions()
544+
.ignoreExceptionsMatching(ITE2ETracingTest::isIgnoredException)
545545
.until(
546546
() -> {
547547
Trace trace = traceClient.getTrace(projectId, customSpanContext.getTraceId());
@@ -1025,4 +1025,12 @@ public void runInTransactionQueryTest() throws Exception {
10251025
Arrays.asList(SPAN_NAME_TRANSACTION_RUN, SPAN_NAME_TRANSACTION_RUN_QUERY),
10261026
Arrays.asList(SPAN_NAME_TRANSACTION_RUN, SPAN_NAME_TRANSACTION_COMMIT)));
10271027
}
1028+
1029+
private static boolean isIgnoredException(Throwable e) {
1030+
String name = e.getClass().getName();
1031+
return name.equals("com.google.api.gax.rpc.NotFoundException")
1032+
|| name.equals("io.grpc.StatusRuntimeException")
1033+
|| name.equals("com.google.api.gax.rpc.DeadlineExceededException")
1034+
|| name.equals("java.lang.IndexOutOfBoundsException");
1035+
}
10281036
}

0 commit comments

Comments
 (0)