记录一下 接手别人项目后使用了系统日志API但是突然报错原因
It is illegal to call this method if the current request is not in asynchron
各种百度查到原因是因为Controller参数中带有其他的参数对象(HttpServletRequest、HttpServletResponse等)导致无法序列化
所有这里用流过滤到没用的参数(HttpServletRequest、HttpServletResponse为例)
Object[] args = joinPoint.getArgs();
Stream<?> stream = ArrayUtils.isEmpty(args) ? Stream.empty() : Arrays.stream(args);
List<Object> logArgs = stream
.filter(arg -> (!(arg instanceof HttpServletRequest) && !(arg instanceof HttpServletResponse)))
.collect(Collectors.toList());
String params = JSONObject.toJSONString(logArgs);