Skip to content

Commit

Permalink
Replace ThreadLocal with TransmittableThreadLocal in HintManager to s…
Browse files Browse the repository at this point in the history
…upport cross Thread usage (#31286)
  • Loading branch information
strongduanmu authored May 19, 2024
1 parent b0b9dce commit 03b7272
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions infra/common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,7 +35,7 @@
@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();

Expand Down

0 comments on commit 03b7272

Please sign in to comment.