Skip to content

Conversation

@olavloite
Copy link
Collaborator

(Creating Draft PR so it's easier to leave comments)

This change adds support for ClientContext in Options and ensures it is
propagated to ExecuteSql, Read, Commit, and BeginTransaction requests.
It aligns with go/spanner-client-scoped-session-state design.

- Added RequestOptions.ClientContext to Options.
- Refactored request option building to Options.toRequestOptionsProto.
- Updated AbstractReadContext, TransactionRunnerImpl, and SessionImpl to use the shared logic.
- Added tests.
This change adds support for setting and propagating ClientContext in the
Spanner Connection API. ClientContext allows propagating client-scoped
session state (e.g., secure parameters) to Spanner RPCs.

- Added setClientContext/getClientContext to Connection interface and implementation.
- Implemented state propagation from Connection to UnitOfWork and its implementations (ReadWriteTransaction, SingleUseTransaction).
- Fixed accidental import removal in OptionsTest.java.
- Fixed TransactionRunnerImplTest to correctly verify ClientContext propagation.
- Added ClientContextMockServerTest for end-to-end verification.
@product-auto-label product-auto-label bot added size: l Pull request size is large. api: spanner Issues related to the googleapis/java-spanner API. labels Jan 21, 2026
}

@Test
public void testBeginTransaction_PropagatesClientContext() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This test seems to be a bit confused about what is the correct/expected behavior.

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

Labels

api: spanner Issues related to the googleapis/java-spanner API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants