This commit is contained in:
parent
07b55f8508
commit
4f5661bff3
|
|
@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -24,6 +25,9 @@ public class CorsFilter implements Filter {
|
||||||
throws IOException, ServletException {
|
throws IOException, ServletException {
|
||||||
// traceId
|
// traceId
|
||||||
Map<String, String> copyOfContextMap = MDC.getCopyOfContextMap();
|
Map<String, String> copyOfContextMap = MDC.getCopyOfContextMap();
|
||||||
|
if(copyOfContextMap == null){
|
||||||
|
copyOfContextMap = new HashMap<>();
|
||||||
|
}
|
||||||
copyOfContextMap.put("traceId",applicationName + IdUtil.getSnowflakeNextId());
|
copyOfContextMap.put("traceId",applicationName + IdUtil.getSnowflakeNextId());
|
||||||
MDC.setContextMap(copyOfContextMap);
|
MDC.setContextMap(copyOfContextMap);
|
||||||
HttpServletResponse response = (HttpServletResponse) resp;
|
HttpServletResponse response = (HttpServletResponse) resp;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue