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 03b72725eb4 Replace ThreadLocal with TransmittableThreadLocal in 
HintManager to support cross Thread usage (#31286)
03b72725eb4 is described below

commit 03b72725eb4296ef4d3f2d0171a031ff3b53c68a
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Sun May 19 16:00:45 2024 +0800

    Replace ThreadLocal with TransmittableThreadLocal in HintManager to support 
cross Thread usage (#31286)
---
 infra/common/pom.xml                                                  | 4 ++++
 .../main/java/org/apache/shardingsphere/infra/hint/HintManager.java   | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/infra/common/pom.xml b/infra/common/pom.xml
index 9c204508a94..5dbe8e92400 100644
--- a/infra/common/pom.xml
+++ b/infra/common/pom.xml
@@ -110,6 +110,10 @@
             <groupId>com.zaxxer</groupId>
             <artifactId>HikariCP</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>transmittable-thread-local</artifactId>
+        </dependency>
     </dependencies>
     
     <build>
diff --git 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/hint/HintManager.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/hint/HintManager.java
index 2e3b8e98ba7..73cc4c98965 100644
--- 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/hint/HintManager.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/hint/HintManager.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.infra.hint;
 
+import com.alibaba.ttl.TransmittableThreadLocal;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ArrayListMultimap;
 import com.google.common.collect.Multimap;
@@ -34,7 +35,7 @@ import java.util.Optional;
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
 public final class HintManager implements AutoCloseable {
     
-    private static final ThreadLocal<HintManager> HINT_MANAGER_HOLDER = new 
ThreadLocal<>();
+    private static final TransmittableThreadLocal<HintManager> 
HINT_MANAGER_HOLDER = new TransmittableThreadLocal<>();
     
     private final Multimap<String, Comparable<?>> databaseShardingValues = 
ArrayListMultimap.create();
     

Reply via email to