Aop 打印参数日志时,出现参数序列化异常。It is illegal to call this method if the current request is not in asynchron
错误信息:
nested exception is java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false)] with root cause:
错误原因:
joinPoint.getArgs()返回的数组中携带有Request(HttpServletRequest)或者Response(HttpServletResponse)对象,导致序列化异常。
解决方案:
//aop中获取请求参数
Object[] args = joinPoint.getArgs();
Stream<?> stream = ArrayUtils.isEmpty(args) ? Stream.empty() : Arrays.asList(args);
List<Object> logArgs = stream.filter(arg -> (!(arg instanceof HttpServletRequest) && !(arg instanceof HttpServletResponse))).collect(Collectors.toList());
//过滤后序列化无异常
String string = JSON.toJSONString(logArgs);
Aop 打印参数日志时,出现参数序列化异常。It is illegal to call this method if the current request is not in asynchron的更多相关文章
- AOP拦截日志类,抛异常:java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode
AOP的日志拦截类中,抛出异常: java.lang.IllegalStateException: It is illegal to call this method if the current r ...
- AOP拦截日志报错llegalStateException: It is illegal to call this method if the current request is not in asynchronous mode
原文链接:https://my.oschina.net/mengzhang6/blog/2395893 关于一次AOP拦截入参记录日志报错的梳理总结 将服务发布到tomcat中后,观察服务的运行状态以 ...
- SpringBoot中使用AOP打印接口日志的方法(转载)
前言 AOP 是 Aspect Oriented Program (面向切面)的编程的缩写.他是和面向对象编程相对的一个概念.在面向对象的编程中,我们倾向于采用封装.继承.多态等概念,将一个个的功能在 ...
- 打印 Logger 日志时,需不需要再封装一下工具类?
在开发过程中,打印日志是必不可少的,因为日志关乎于应用的问题排查.应用监控等.现在打印日志一般都是使用 slf4j,因为使用日志门面,有助于打印方式统一,即使后面更换日志框架,也非常方便.在 < ...
- AOP打印请求日志,打印返回值
@Aspect // 申明是个spring管理的bean @Component @Slf4j public class LogAspectServiceApi { private JSONObject ...
- Log4j2打印一行日志时返回本行日志的字符串
import org.apache.logging.log4j.Level; import org.apache.logging.log4j.core.impl.Log4jLogEvent; impo ...
- Springboot AOP写操作日志 GET POST
pom.xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId> ...
- IDEA打印gc日志,设置JVM参数方法
打印gc日志 1.对指定运行程序输出GC日志: 点击edit configurations... 在vm options处加入-XX:+PrintGCDetails 测试:代码调用system.gc后 ...
- Linux 打印可变参数日志
实现了传输进去的字符串所在的文档,函数和行数显示功能. 实现了将传入的可变参数打印到日志功能. #include<stdio.h> #include<stdarg.h> #in ...
随机推荐
- 百度编辑器contentChange监听不到图片上传
将ueditor组件化到java项目中,当调用组件后,绑定函数,监听contentchange如下图: um.addListener("contentChange",functio ...
- 透过字节码分析Java动态代理机制。
一.创建动态代理代码 1.创建接口 public interface Subject { void request(); } 2.创建接口实现类 public class RealSubject im ...
- Cent0S 6.7直接在/etc/resolv.conf文件下修改DNS地址重启不生效问题【转】
CentOS 6.7/Linux下设置IP地址 1:临时修改: 1.1:修改IP地址 # ifconfig eth0 192.168.2.104 1.2:修改网关地址 # route add defa ...
- socat管理haproxy配置 ssh-keygen -N '' -t rsa -q -b 2048
socat管理haproxy配置 haproxy是可以通过socat命令管理haproxy.cfg文件的:1.安装socat yum install socat -y 2.配置haproxy.cf ...
- linux内核的0号进程是在哪里创建的?
1. 0号进程即为idle进程或swapper进程,也就是空闲进程 2. 0号进程特点 idle是一个进程,其pid为0. 主处理器上的idle由原始进程(pid=0)演变而来.从处理器上的idle由 ...
- ffmpeg编译错误,提示找不到相应的shared libraries :libavdevice.so.53
解决方法:需要配置响应的环境变量,以便能找到响应的lib库 vi /etc/ld.so.conf 加入 /usr/local/lib 执行 sudo ldconfig
- git---主分支同步到子分支
在进行git项目协同开发的时候,每个分支的代码会被合并到主分支 master 分支上,但是如何将master分支上的代码合并到子分支上呢? 第一步:切换到本地的仓库,更新为最新的代码. 第二步:切换到 ...
- 使用 ASP.NET Core 创建 Web API及链接sqlserver数据库
创建 Web API https://docs.microsoft.com/zh-cn/aspnet/core/tutorials/first-web-api?view=aspnetcore-3.0& ...
- Python3基础 交换两个变量的值
Python : 3.7.3 OS : Ubuntu 18.04.2 LTS IDE : pycharm-community-2019.1.3 ...
- 003-guava 集合-不可变集合
一.概述 二.使用 2.1.不可变集合 1.为什么使用不可变集合 不可变对象有很多优点,包括: 当对象被不可信的库调用时,不可变形式是安全的:不可变对象被多个线程调用时,不存在竞态条件问题不可变集合不 ...