Skip to content

Commit 9608560

Browse files
olavloiteodeke-em
authored andcommitted
chore: fix failing test cases
1 parent d08e24c commit 9608560

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,11 +2034,12 @@ <ReqT, RespT> GrpcCallContext newCallContext(
20342034
MethodDescriptor<ReqT, RespT> method,
20352035
boolean routeToLeader) {
20362036
GrpcCallContext context = this.baseGrpcCallContext;
2037-
if (options != null) {
2037+
Long affinity = options == null ? null : Option.CHANNEL_HINT.getLong(options);
2038+
if (affinity != null) {
20382039
if (this.isGrpcGcpExtensionEnabled) {
20392040
// Set channel affinity in gRPC-GCP.
20402041
// Compute bounded channel hint to prevent gRPC-GCP affinity map from getting unbounded.
2041-
int boundedChannelHint = Option.CHANNEL_HINT.getLong(options).intValue() % this.numChannels;
2042+
int boundedChannelHint = affinity.intValue() % this.numChannels;
20422043
context =
20432044
context.withCallOptions(
20442045
context
@@ -2047,11 +2048,10 @@ <ReqT, RespT> GrpcCallContext newCallContext(
20472048
GcpManagedChannel.AFFINITY_KEY, String.valueOf(boundedChannelHint)));
20482049
} else {
20492050
// Set channel affinity in GAX.
2050-
Long affinity = Option.CHANNEL_HINT.getLong(options);
2051-
if (affinity != null) {
2052-
context = context.withChannelAffinity(affinity.intValue());
2053-
}
2051+
context = context.withChannelAffinity(affinity.intValue());
20542052
}
2053+
}
2054+
if (options != null) {
20552055
context = withRequestId(context, options);
20562056
}
20572057
context = context.withExtraHeaders(metadataProvider.newExtraHeaders(resource, projectName));

google-cloud-spanner/src/test/java/com/google/cloud/spanner/TransactionManagerImplTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public void usesPreparedTransaction() {
241241
Mockito.anyString(),
242242
Mockito.anyString(),
243243
Mockito.anyMap(),
244-
Mockito.eq(null),
244+
Mockito.anyMap(),
245245
Mockito.eq(true)))
246246
.thenAnswer(
247247
invocation ->
@@ -324,7 +324,7 @@ public void inlineBegin() {
324324
Mockito.anyString(),
325325
Mockito.anyString(),
326326
Mockito.anyMap(),
327-
Mockito.eq(null),
327+
Mockito.anyMap(),
328328
Mockito.eq(true)))
329329
.thenAnswer(
330330
invocation ->

google-cloud-spanner/src/test/java/com/google/cloud/spanner/TransactionRunnerImplTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public void usesPreparedTransaction() {
193193
Mockito.anyString(),
194194
Mockito.anyString(),
195195
Mockito.anyMap(),
196-
Mockito.eq(null),
196+
Mockito.anyMap(),
197197
Mockito.eq(true)))
198198
.thenAnswer(
199199
invocation ->

0 commit comments

Comments
 (0)