(improvement)(code) Replace e.printStackTrace() with logger.error. (#1156)

This commit is contained in:
lexluo09
2024-06-15 18:26:52 +08:00
committed by GitHub
parent b5cc450758
commit f2a12e56b7
9 changed files with 39 additions and 36 deletions

View File

@@ -5,6 +5,7 @@ import com.tencent.supersonic.auth.api.authentication.constant.UserConstants;
import com.tencent.supersonic.auth.authentication.service.UserServiceImpl;
import com.tencent.supersonic.auth.authentication.utils.UserTokenUtils;
import com.tencent.supersonic.common.util.S2ThreadContext;
import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.connector.RequestFacade;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.util.Strings;
@@ -17,7 +18,7 @@ import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;
@Slf4j
public abstract class AuthenticationInterceptor implements HandlerInterceptor {
@@ -64,7 +65,7 @@ public abstract class AuthenticationInterceptor implements HandlerInterceptor {
return StringUtils.isNotBlank(appId);
}
protected void reflectSetparam(HttpServletRequest request, String key, String value) {
protected void reflectSetParam(HttpServletRequest request, String key, String value) {
try {
if (request instanceof StandardMultipartHttpServletRequest) {
RequestFacade servletRequest =
@@ -98,7 +99,7 @@ public abstract class AuthenticationInterceptor implements HandlerInterceptor {
o2.addValue(key).setString(value);
}
} catch (Exception e) {
e.printStackTrace();
log.error("reflectSetParam error:", e);
}
}
}

View File

@@ -67,7 +67,7 @@ public class DefaultAuthenticationInterceptor extends AuthenticationInterceptor
private void setFakerUser(HttpServletRequest request) {
String token = userTokenUtils.generateAdminToken(request);
reflectSetparam(request, authenticationConfig.getTokenHttpHeaderKey(), token);
reflectSetParam(request, authenticationConfig.getTokenHttpHeaderKey(), token);
setContext(User.getFakeUser().getName(), request);
}