This is an automated email from the ASF dual-hosted git repository.

zhaojinchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 8a253d6967e Remove unused setTransactionType method (#31008)
8a253d6967e is described below

commit 8a253d6967e85d0c996df470a807dd715dd2522f
Author: ZhangCheng <[email protected]>
AuthorDate: Thu Apr 25 16:16:32 2024 +0800

    Remove unused setTransactionType method (#31008)
---
 .../backend/session/transaction/TransactionStatus.java     | 14 +-------------
 .../proxy/backend/session/ConnectionSessionTest.java       | 11 -----------
 .../backend/session/transaction/TransactionStatusTest.java |  9 ---------
 3 files changed, 1 insertion(+), 33 deletions(-)

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 014a9d38c11..290c28c12d4 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 @@ package 
org.apache.shardingsphere.proxy.backend.session.transaction;
 
 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 @@ public final class TransactionStatus {
     @Setter
     private volatile boolean inTransaction;
     
-    private volatile TransactionType transactionType;
+    private final TransactionType transactionType;
     
     @Setter
     private volatile boolean exceptionOccur;
@@ -41,16 +39,6 @@ public final class TransactionStatus {
         transactionType = initialTransactionType;
     }
     
-    /**
-     * 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.
      * 
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 845ae3c9ad8..bf1e56dc06d 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.proxy.backend.context.ProxyContext;
 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.hamcrest.MatcherAssert.assertThat;
 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;
@@ -71,15 +69,6 @@ class ConnectionSessionTest {
         assertThat(connectionSession.getDatabaseName(), is("currentDatabase"));
     }
     
-    @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");
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 370c693f3ba..bfff4b7d011 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.apache.shardingsphere.transaction.api.TransactionType;
 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 {
@@ -34,13 +32,6 @@ class TransactionStatusTest {
         transactionStatus = new TransactionStatus(TransactionType.XA);
     }
     
-    @Test
-    void assertSetTransactionType() {
-        transactionStatus.setTransactionType(TransactionType.BASE);
-        TransactionType actual = transactionStatus.getTransactionType();
-        assertThat(actual, is(TransactionType.BASE));
-    }
-    
     @Test
     void assertSetInTransaction() {
         transactionStatus.setInTransaction(true);

Reply via email to