fix(20240829): 数组越界问题

This commit is contained in:
luofu 2024-08-29 11:51:47 +08:00
parent 6c0a500847
commit 4640cb77a1

View File

@ -9,6 +9,7 @@ import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
@ -42,8 +43,15 @@ public class RequestLog {
stopWatch.start();
Object proceed = joinPoint.proceed();
stopWatch.stop();
log.info("[response]返回记录: latency = {} responseParam = {}", stopWatch.getTotalTimeMillis(),
JSONUtil.toJsonStr(proceed).substring(0,1000));
log.info("[response]返回记录: latency = {} responseParam = {}", stopWatch.getTotalTimeMillis(), subString(JSONUtil.toJsonStr(proceed)));
return proceed;
}
private String subString(String str) {
if (StringUtils.hasText(str) && str.length() > 1000) {
return str.substring(0, 1000);
} else {
return str;
}
}
}