Skip to content

Conversation

@pem70
Copy link
Contributor

@pem70 pem70 commented Oct 10, 2025

Summary

This PR fixes a flaky test readUnmatachableTypesTest in
spring-cloud-gcp-data-spanner/src/test/java/com/google/cloud/spring/data/spanner/core/convert/ConverterAwareMappingSpannerEntityReaderTests.java.

The original test asserted an exact exception message:

.hasMessage("Unable to read column from Cloud Spanner results: id");

However, the order in which entity fields are processed is non-deterministic (due to reflection order).
As a result, the first failing field—and thus the message suffix—can vary between runs, leading to intermittent test failures.

Root Cause

  • SpannerEntityReader uses reflection over entity fields, which does not guarantee order.
  • The test relied on a fixed exception message, making it brittle to iteration changes.

Fix

The test has been updated to:

  • Provide explicit read parameters for deterministic field mapping.
  • Assert message content rather than full equality.
  • Retain a stable suffix check for : id.

Additional

There is a typo from the original test name, which is not modified due to consistency.

@pem70 pem70 requested a review from a team as a code owner October 10, 2025 02:11
@google-cla
Copy link

google-cla bot commented Oct 10, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@pem70 pem70 marked this pull request as draft October 10, 2025 02:18
@pem70 pem70 force-pushed the Fix-readUnmatachableTypesTest branch from 7fc1d2c to e3929f8 Compare October 10, 2025 02:21
@pem70 pem70 marked this pull request as ready for review October 10, 2025 02:22
@pem70
Copy link
Contributor Author

pem70 commented Oct 10, 2025

This PR addressed issue #4186

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