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 ...
随机推荐
- Java实现简单RPC框架(转)
一.RPC简介 RPC,全称Remote Procedure Call, 即远程过程调用,它是一个计算机通信协议.它允许像本地服务一样调用远程服务.它可以有不同的实现方式.如RMI(远程方法调用).H ...
- TP5 查询 字符串条件如何实现
TP5 查询 字符串条件如何实现 当查询条件是 (1,3,8) ,3,4) 这种情况改如何查询呢? 主要用到FIND_IN_SET $where[ ]=>['exp',Db::raw(& ...
- mysql批量更新update中的锁表机制
mysql的行锁是通过索引加载的,即行锁是加在索引响应的行上的,要是对应的SQL语句没有走索引,则会全表扫描,行锁则无法实现,取而代之的是表锁. CREATE TABLE SIMPLE_USER( I ...
- 【json/regex】将简单对象生成的json文进行内部排序后再输出
有这样一个实体类: package com.hy; public class Emp { private int id; private int age; private String name; p ...
- np.vstack()和np.hstack()
本文链接:https://blog.csdn.net/m0_37393514/article/details/79538748在这里我们介绍两个拼接数组的方法: np.vstack():在竖直方向上堆 ...
- How to: Secure Connection Strings When Using Data Source Controls
https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-3.0/dx0f3cf2(v=vs.85) When wo ...
- ifc osg施工现场模拟
基于ifc数据模型的施工现场模拟
- QString int
QString转int 直接调用toInt()函数 例: QString str("100"); int tmp = str.toInt(); 或者: bool ok; QStri ...
- mysql存储过程中declare 和set 定义变量的区别
declare为对变量进行声明,声明必须制定变量的数据类型,只能写在过程的前面set是对变量赋值,可以放在过程的任何地方对没有declare声明过的变量赋值,该变量必须以加上@号,否则会报错 DECL ...
- C# WebClient 无法设置超时时间的解决办法
http://www.lenashane.com/article/20150624-1021.html