判空
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user