Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions trpc-core/src/main/java/org/slf4j/TrpcMDCAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@

import com.alibaba.ttl.TransmittableThreadLocal;
import com.tencent.trpc.core.utils.StringUtils;
import java.util.Deque;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.helpers.ThreadLocalMapOfStacks;
import org.slf4j.spi.MDCAdapter;

/**
Expand All @@ -39,6 +41,7 @@ public class TrpcMDCAdapter implements MDCAdapter {
private static final TrpcMDCAdapter mtcMDCAdapter;

private final ThreadLocal<Map<String, String>> copyOnInheritThreadLocal = new TransmittableThreadLocal<>();
private final ThreadLocalMapOfStacks threadLocalMapOfDeques = new ThreadLocalMapOfStacks();

/**
* Keeps track of the last operation performed
Expand Down Expand Up @@ -141,6 +144,22 @@ public Map<String, String> getCopyOfContextMap() {
.map(HashMap::new).orElse(null);
}

public void pushByKey(String key, String value) {
this.threadLocalMapOfDeques.pushByKey(key, value);
}

public String popByKey(String key) {
return this.threadLocalMapOfDeques.popByKey(key);
}

public Deque<String> getCopyOfDequeByKey(String key) {
return this.threadLocalMapOfDeques.getCopyOfDequeByKey(key);
}

public void clearDequeByKey(String key) {
this.threadLocalMapOfDeques.clearDequeByKey(key);
}

@SuppressWarnings("unchecked")
@Override
public void setContextMap(Map contextMap) {
Expand Down
8 changes: 4 additions & 4 deletions trpc-dependencies/trpc-dependencies-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
<javassist.version>3.28.0-GA</javassist.version>
<javax.servlet-api.version>3.1.0</javax.servlet-api.version>
<jsr305.version>3.0.2</jsr305.version>
<logback.version>1.2.13</logback.version>
<logging.log4j.version>2.17.1</logging.log4j.version>
<log4j2.ttl.thread.context.map.version>1.3.3</log4j2.ttl.thread.context.map.version>
<logback.version>1.5.15</logback.version>
<logging.log4j.version>2.24.3</logging.log4j.version>
<log4j2.ttl.thread.context.map.version>1.4.0</log4j2.ttl.thread.context.map.version>
<maven.gpg.version>3.1.0</maven.gpg.version>
<maven.deploy.version>3.0.0</maven.deploy.version>
<maven.source.version>3.0.1</maven.source.version>
Expand Down Expand Up @@ -94,7 +94,7 @@
<resteasy.version>5.0.6.Final</resteasy.version>
<sentinel-transport-simple-http.version>1.8.6</sentinel-transport-simple-http.version>
<sentinel.version>1.8.6</sentinel.version>
<slf4j.version>1.7.36</slf4j.version>
<slf4j.version>2.0.16</slf4j.version>
<snakeyaml.version>2.0</snakeyaml.version>
<snappy.version>1.1.10.4</snappy.version>
<spring.version>5.3.27</spring.version>
Expand Down
Loading