Remove unused setTransactionType method (#31008)
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/session/transaction/TransactionStatus.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/session/transaction/TransactionStatus.java
index 014a9d3..290c28c 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/session/transaction/TransactionStatus.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/session/transaction/TransactionStatus.java
@@ -19,9 +19,7 @@
import lombok.Getter;
import lombok.Setter;
-import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.transaction.api.TransactionType;
-import org.apache.shardingsphere.transaction.exception.SwitchTypeInTransactionException;
/**
* Transaction status.
@@ -32,7 +30,7 @@
@Setter
private volatile boolean inTransaction;
- private volatile TransactionType transactionType;
+ private final TransactionType transactionType;
@Setter
private volatile boolean exceptionOccur;
@@ -42,16 +40,6 @@
}
/**
- * Change transaction type of current channel.
- *
- * @param transactionType transaction type
- */
- public void setTransactionType(final TransactionType transactionType) {
- ShardingSpherePreconditions.checkState(!inTransaction, SwitchTypeInTransactionException::new);
- this.transactionType = transactionType;
- }
-
- /**
* Judge whether in connection held transaction.
*
* @return is in connection held transaction or not
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/session/ConnectionSessionTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/session/ConnectionSessionTest.java
index 845ae3c..bf1e56d 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/session/ConnectionSessionTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/session/ConnectionSessionTest.java
@@ -27,7 +27,6 @@
import org.apache.shardingsphere.test.mock.AutoMockExtension;
import org.apache.shardingsphere.test.mock.StaticMockSettings;
import org.apache.shardingsphere.transaction.api.TransactionType;
-import org.apache.shardingsphere.transaction.exception.SwitchTypeInTransactionException;
import org.apache.shardingsphere.transaction.rule.TransactionRule;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -43,7 +42,6 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -72,15 +70,6 @@
}
@Test
- void assertFailedSwitchTransactionTypeWhileBegin() {
- connectionSession.setCurrentDatabase("db");
- ContextManager contextManager = mockContextManager();
- when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
- new BackendTransactionManager(databaseConnectionManager).begin();
- assertThrows(SwitchTypeInTransactionException.class, () -> connectionSession.getTransactionStatus().setTransactionType(TransactionType.XA));
- }
-
- @Test
void assertSwitchSchemaWhileBegin() {
connectionSession.setCurrentDatabase("db");
ContextManager contextManager = mockContextManager();
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/session/transaction/TransactionStatusTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/session/transaction/TransactionStatusTest.java
index 370c693..bfff4b7 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/session/transaction/TransactionStatusTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/session/transaction/TransactionStatusTest.java
@@ -21,8 +21,6 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;
class TransactionStatusTest {
@@ -35,13 +33,6 @@
}
@Test
- void assertSetTransactionType() {
- transactionStatus.setTransactionType(TransactionType.BASE);
- TransactionType actual = transactionStatus.getTransactionType();
- assertThat(actual, is(TransactionType.BASE));
- }
-
- @Test
void assertSetInTransaction() {
transactionStatus.setInTransaction(true);
boolean actual = transactionStatus.isInConnectionHeldTransaction();