You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/07/19 12:14:01 UTC
[shardingsphere] branch master updated: Fix occasional unit test failure caused by ThreadLocal leak (#19362)
This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 acfb4f48ecd Fix occasional unit test failure caused by ThreadLocal leak (#19362)
acfb4f48ecd is described below
commit acfb4f48ecdaea00a4c2f2df91e9765e5c13c214
Author: 吴伟杰 <wu...@apache.org>
AuthorDate: Tue Jul 19 20:13:44 2022 +0800
Fix occasional unit test failure caused by ThreadLocal leak (#19362)
---
.../shardingsphere/driver/executor/AbstractBaseExecutorTest.java | 1 +
.../shardingsphere/driver/jdbc/adapter/ConnectionAdapterTest.java | 7 +++++++
.../jdbc/unsupported/UnsupportedOperationConnectionTest.java | 7 +++++++
.../apache/shardingsphere/driver/state/DriverStateContextTest.java | 7 +++++++
.../apache/shardingsphere/driver/state/ok/OKDriverStateTest.java | 7 +++++++
5 files changed, 29 insertions(+)
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/AbstractBaseExecutorTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/AbstractBaseExecutorTest.java
index aaf43d07ac0..1b72625e62d 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/AbstractBaseExecutorTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/AbstractBaseExecutorTest.java
@@ -111,5 +111,6 @@ public abstract class AbstractBaseExecutorTest {
@After
public void tearDown() {
executorEngine.close();
+ TransactionTypeHolder.clear();
}
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/ConnectionAdapterTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/ConnectionAdapterTest.java
index 455c25d5a1d..01a72c9816b 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/ConnectionAdapterTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/ConnectionAdapterTest.java
@@ -24,7 +24,9 @@ import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRule
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.traffic.rule.TrafficRule;
import org.apache.shardingsphere.traffic.rule.builder.DefaultTrafficRuleConfigurationBuilder;
+import org.apache.shardingsphere.transaction.core.TransactionTypeHolder;
import org.apache.shardingsphere.transaction.rule.TransactionRule;
+import org.junit.After;
import org.junit.Test;
import java.sql.Connection;
@@ -89,4 +91,9 @@ public final class ConnectionAdapterTest {
when(globalRuleMetaData.getSingleRule(TrafficRule.class)).thenReturn(new TrafficRule(new DefaultTrafficRuleConfigurationBuilder().build()));
return new ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, contextManager, mock(JDBCContext.class));
}
+
+ @After
+ public void tearDown() {
+ TransactionTypeHolder.clear();
+ }
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationConnectionTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationConnectionTest.java
index 021c82a0b41..f9752d42ca2 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationConnectionTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationConnectionTest.java
@@ -23,7 +23,9 @@ import org.apache.shardingsphere.infra.database.DefaultDatabase;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.traffic.rule.TrafficRule;
+import org.apache.shardingsphere.transaction.core.TransactionTypeHolder;
import org.apache.shardingsphere.transaction.rule.TransactionRule;
+import org.junit.After;
import org.junit.Test;
import java.sql.SQLException;
@@ -136,4 +138,9 @@ public final class UnsupportedOperationConnectionTest {
public void assertSetClientInfoWithProperties() {
shardingSphereConnection.setClientInfo(new Properties());
}
+
+ @After
+ public void tearDown() {
+ TransactionTypeHolder.clear();
+ }
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/state/DriverStateContextTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/state/DriverStateContextTest.java
index 470c6e9a9bd..0c52eca08ac 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/state/DriverStateContextTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/state/DriverStateContextTest.java
@@ -31,7 +31,9 @@ import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
import org.apache.shardingsphere.traffic.rule.TrafficRule;
+import org.apache.shardingsphere.transaction.core.TransactionTypeHolder;
import org.apache.shardingsphere.transaction.rule.TransactionRule;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -79,4 +81,9 @@ public final class DriverStateContextTest {
Connection actual = DriverStateContext.getConnection(DefaultDatabase.LOGIC_NAME, contextManager, mock(JDBCContext.class));
assertThat(actual, instanceOf(ShardingSphereConnection.class));
}
+
+ @After
+ public void tearDown() {
+ TransactionTypeHolder.clear();
+ }
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/state/ok/OKDriverStateTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/state/ok/OKDriverStateTest.java
index 44ecf6abd04..84aba9ae778 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/state/ok/OKDriverStateTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/state/ok/OKDriverStateTest.java
@@ -23,7 +23,9 @@ import org.apache.shardingsphere.infra.database.DefaultDatabase;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.traffic.rule.TrafficRule;
+import org.apache.shardingsphere.transaction.core.TransactionTypeHolder;
import org.apache.shardingsphere.transaction.rule.TransactionRule;
+import org.junit.After;
import org.junit.Test;
import java.sql.Connection;
@@ -46,4 +48,9 @@ public final class OKDriverStateTest {
Connection actual = new OKDriverState().getConnection(DefaultDatabase.LOGIC_NAME, contextManager, mock(JDBCContext.class));
assertThat(actual, instanceOf(ShardingSphereConnection.class));
}
+
+ @After
+ public void tearDown() {
+ TransactionTypeHolder.clear();
+ }
}