Skip to content

Reject withDurability(durabilityLevel) in transactions. #1504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ private void rejectInvalidTransactionalOptions() {
if (this.expiry != null) {
throw new IllegalArgumentException("withExpiry is not supported in a transaction");
}
if (this.durabilityLevel != null && this.durabilityLevel != DurabilityLevel.NONE) {
throw new IllegalArgumentException("withDurability is not supported in a transaction");
}
if (this.options != null) {
throw new IllegalArgumentException("withOptions is not supported in a transaction");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ private void rejectInvalidTransactionalOptions() {
throw new IllegalArgumentException(
"withDurability PersistTo and ReplicateTo overload is not supported in a transaction");
}
if (this.durabilityLevel != null && this.durabilityLevel != DurabilityLevel.NONE) {
throw new IllegalArgumentException("withDurability is not supported in a transaction");
}
if (this.options != null) {
throw new IllegalArgumentException("withOptions is not supported in a transaction");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ private void rejectInvalidTransactionalOptions() {
if (this.expiry != null) {
throw new IllegalArgumentException("withExpiry is not supported in a transaction");
}
if (this.durabilityLevel != null && this.durabilityLevel != DurabilityLevel.NONE) {
throw new IllegalArgumentException("withDurability is not supported in a transaction");
}
if (this.options != null) {
throw new IllegalArgumentException("withOptions is not supported in a transaction");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.function.Consumer;
import java.util.function.Function;

import com.couchbase.client.core.msg.kv.DurabilityLevel;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
Expand Down Expand Up @@ -53,6 +54,7 @@
* will be rejected at runtime.
*
* @author Graham Pople
* @author Michael Reiche
*/
@IgnoreWhen(missesCapabilities = Capabilities.QUERY, clusterTypes = ClusterType.MOCKED)
@SpringJUnitConfig(classes = { TransactionsConfig.class,
Expand Down Expand Up @@ -103,6 +105,14 @@ public void insertWithExpiry() {
});
}

@DisplayName("Using insertById().withDurability(durabilityLevel) in a transaction is rejected at runtime")
@Test
public void insertWithDurability2() {
test((ops) -> {
ops.insertById(Person.class).withDurability(DurabilityLevel.MAJORITY).one(WalterWhite);
});
}

@DisplayName("Using insertById().withOptions in a transaction is rejected at runtime")
@Test
public void insertWithOptions() {
Expand All @@ -127,6 +137,14 @@ public void replaceWithExpiry() {
});
}

@DisplayName("Using replaceById().withDurability(durabilityLevel) in a transaction is rejected at runtime")
@Test
public void replaceWithDurability2() {
test((ops) -> {
ops.replaceById(Person.class).withDurability(DurabilityLevel.MAJORITY).one(WalterWhite);
});
}

@DisplayName("Using replaceById().withOptions in a transaction is rejected at runtime")
@Test
public void replaceWithOptions() {
Expand All @@ -143,6 +161,14 @@ public void removeWithDurability() {
});
}

@DisplayName("Using removeById().withDurability(durabilityLevel) in a transaction is rejected at runtime")
@Test
public void removeWithDurability2() {
test((ops) -> {
ops.removeById(Person.class).withDurability(DurabilityLevel.MAJORITY).oneEntity(WalterWhite);
});
}

@DisplayName("Using removeById().withOptions in a transaction is rejected at runtime")
@Test
public void removeWithOptions() {
Expand Down