Skip to content

Commit eeadf25

Browse files
committed
SCBC-469: Scala incorrectly declaring support for transactions protocol 2.1
Declare support for protocol 2.1 or 2.0 based on the provided extensions. Change-Id: I45da0bb1e294d9232ee6c0244776ec578c208445 Reviewed-on: https://review.couchbase.org/c/couchbase-jvm-clients/+/213605 Reviewed-by: Aaliya Haque <[email protected]> Tested-by: Build Bot <[email protected]>
1 parent ff7a0c2 commit eeadf25

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
lines changed

core-io/src/main/java/com/couchbase/client/core/transaction/forwards/CoreTransactionsSupportedExtensions.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.couchbase.client.core.transaction.forwards;
1717

1818
import com.couchbase.client.core.annotation.Stability;
19+
import com.couchbase.client.core.util.CbCollections;
1920

2021
import java.util.Arrays;
2122
import java.util.Set;
@@ -31,12 +32,27 @@
3132
public class CoreTransactionsSupportedExtensions {
3233
public static final CoreTransactionsSupportedExtensions NONE = from();
3334
public static final CoreTransactionsSupportedExtensions ALL = from(CoreTransactionsExtension.values());
35+
private static final Set<CoreTransactionsExtension> ALL_2_1 = CbCollections.setOf(CoreTransactionsExtension.EXT_TRANSACTION_ID,
36+
CoreTransactionsExtension.EXT_TIME_OPT_UNSTAGING,
37+
CoreTransactionsExtension.EXT_BINARY_METADATA,
38+
CoreTransactionsExtension.EXT_CUSTOM_METADATA_COLLECTION,
39+
CoreTransactionsExtension.EXT_QUERY,
40+
CoreTransactionsExtension.EXT_STORE_DURABILITY,
41+
CoreTransactionsExtension.BF_CBD_3838,
42+
CoreTransactionsExtension.BF_CBD_3787,
43+
CoreTransactionsExtension.BF_CBD_3705,
44+
CoreTransactionsExtension.BF_CBD_3794,
45+
CoreTransactionsExtension.EXT_REMOVE_COMPLETED,
46+
CoreTransactionsExtension.EXT_ALL_KV_COMBINATIONS,
47+
CoreTransactionsExtension.EXT_UNKNOWN_ATR_STATES,
48+
CoreTransactionsExtension.BF_CBD_3791,
49+
CoreTransactionsExtension.EXT_SINGLE_QUERY);
3450

3551
public final Set<CoreTransactionsExtension> extensions;
3652
private final Set<String> extensionIds;
3753

38-
public final int protocolMajor = 2;
39-
public final int protocolMinor = 1;
54+
private final int protocolMajor = 2;
55+
private final int protocolMinor;
4056

4157
private CoreTransactionsSupportedExtensions(Iterable<CoreTransactionsExtension> extensions) {
4258
this.extensions = unmodifiableSet(newEnumSet(CoreTransactionsExtension.class, extensions));
@@ -45,6 +61,15 @@ private CoreTransactionsSupportedExtensions(Iterable<CoreTransactionsExtension>
4561
.map(CoreTransactionsExtension::value)
4662
.collect(toSet())
4763
);
64+
this.protocolMinor = this.extensions.equals(ALL_2_1) ? 1 : 0;
65+
}
66+
67+
public int protocolMajor() {
68+
return protocolMajor;
69+
}
70+
71+
public int protocolMinor() {
72+
return protocolMinor;
4873
}
4974

5075
public static CoreTransactionsSupportedExtensions from(CoreTransactionsExtension... extensions) {

core-io/src/main/java/com/couchbase/client/core/transaction/forwards/ForwardCompatRequirement.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ class ForwardCompatProtocolRequirement extends ForwardCompatRequirement {
6767
}
6868

6969
public ForwardCompatBehaviourFull behaviour(CoreTransactionsSupportedExtensions supported) {
70-
if (supported.protocolMajor > minProtocolMajor) {
70+
if (supported.protocolMajor() > minProtocolMajor) {
7171
return ForwardCompatBehaviourFull.CONTINUE;
7272
}
73-
if (supported.protocolMajor < minProtocolMajor) {
73+
if (supported.protocolMajor() < minProtocolMajor) {
7474
return behaviour;
7575
}
76-
if (supported.protocolMinor < minProtocolMinor) {
76+
if (supported.protocolMinor() < minProtocolMinor) {
7777
return behaviour;
7878
}
7979
return ForwardCompatBehaviourFull.CONTINUE;

java-fit-performer/src/main/java/com/couchbase/JavaPerformer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ protected void customisePerformerCaps(PerformerCapsFetchResponse.Builder respons
159159
}
160160

161161
var supported = CoreTransactionsSupportedExtensions.ALL;
162-
var protocolVersion = supported.protocolMajor + "." + supported.protocolMinor;
162+
var protocolVersion = supported.protocolMajor() + "." + supported.protocolMinor();
163163

164164
response.setTransactionsProtocolVersion(protocolVersion);
165165

scala-fit-performer/src/main/scala/com/couchbase/client/performer/scala/ScalaPerformer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class ScalaPerformer extends CorePerformer {
9999
// [if:1.7.2]
100100
response.addPerformerCaps(Caps.TRANSACTIONS_SUPPORT_1)
101101
val supported = Supported
102-
val protocolVersion = supported.protocolMajor + "." + supported.protocolMinor
102+
val protocolVersion = supported.protocolMajor() + "." + supported.protocolMinor()
103103
response.setTransactionsProtocolVersion(protocolVersion)
104104
val sdkVersionRaw = VersionUtil.introspectSDKVersionScala
105105
val sdkVersion = if (sdkVersionRaw == null) {

0 commit comments

Comments
 (0)