Skip to content

test(spanner): unflake java8-samples - #14938

Open
sakthivelmanii wants to merge 1 commit into
mainfrom
unflake-cloud-devrel-client-libraries-java-java-spanner-
Open

sakthivelmanii wants to merge 1 commit into
mainfrom
unflake-cloud-devrel-client-libraries-java-java-spanner-

Conversation

@sakthivelmanii

Copy link
Copy Markdown
Contributor

Problem

  • The PgSpannerSample.java code catches an ExecutionException and attempts to cast its cause directly to a SpannerException.
  • The cause is actually a com.google.api.gax.rpc.FailedPreconditionException, resulting in a ClassCastException.
  • This causes the java8-samples test to fail.

Solution

  • Use SpannerExceptionFactory.asSpannerException(e.getCause()) to correctly convert or wrap the GAX exception into a SpannerException instead of casting directly.

…r/nightly/java8-samples

Fix ClassCastException by correctly wrapping GAX exceptions using SpannerExceptionFactory.
@sakthivelmanii
sakthivelmanii requested review from a team as code owners November 6, 2026 12:11
@sakthivelmanii
sakthivelmanii enabled auto-merge (squash) November 6, 2026 12:11
@sakthivelmanii

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates several database administration methods in PgSpannerSample.java to safely handle ExecutionException. Instead of directly casting e.getCause() to SpannerException, which could lead to a ClassCastException if the cause is of a different type, the code now utilizes SpannerExceptionFactory.asSpannerException(e.getCause()) to perform a safe conversion. There are no review comments, so I have no additional feedback to provide.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates PgSpannerSample.java to replace direct casting of e.getCause() to SpannerException with SpannerExceptionFactory.asSpannerException(e.getCause()) across multiple database administration methods. This prevents potential ClassCastException issues if the cause of the ExecutionException is not a SpannerException. There are no review comments to address, and I have no additional feedback to provide.

@sakthivelmanii sakthivelmanii changed the title test(spanner): unflake cloud-devrel/client-libraries/java/java-spanner/nightly/java8-samples test(spanner): unflake java8-samples Nov 6, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant