Comments (6)
看了下,我是用的java.util.ArrayList#ArrayList(java.util.Collection<? extends E>)构造方法,所以是塞了Map的value数组构造进去的。
你可以用这个单测case试下cn.monitor4all.logRecord.test.OperationLogNormalTest#testMethodThrowException
from log-record.
具体说说?没看出来。
from log-record.
@DaTa
public class LogDTO {
private boolean success;
private String exception;
}
public class Test001 {
public static void main(String[] args) {
List<LogDTO> logDTOList = new ArrayList<>(3);
System.out.println("------000-------" + logDTOList.size());
logDTOList.forEach(logDTO -> { // 此处的是否有问题??
logDTO.setSuccess(false);
logDTO.setException("throwable.getMessage()");
System.out.println("-------------");
});
System.out.println("------1111-------" + logDTOList.size());
for(LogDTO logDTO : logDTOList){
System.out.println("-------------"+logDTO.getException());
}
}
}
我的运行结果:
------000-------0
------1111-------0
Process finished with exit code 0
说明 logDTOList.forEach() 根本不会执行
是不是可以说finally 里面的 logDTOList.forEach() 也不会执行,也就是说原方法异常时,不会保存任何操作记录
from log-record.
你注解@OperationLog一行具体是怎么写的?
我看你上方的代码, new ArrayList<>(3); 然后也没塞值给数组,前后都是0没问题吧。
from log-record.
这个跟@OperationLog 注解没关系吧,
AOP中,原方法异常,进到catch模块,
// 写入异常执行后日志
logDTOList = new ArrayList<>(logDtoMap.values());
logDTOList.forEach(logDTO -> {
logDTO.setSuccess(false);
logDTO.setException(throwable.getMessage());
});
这段代码跟我写的demo 功能一样吧,没有往logDTOList里塞任何数据,就forEach了
最后在执行finally 模块时,不启用线程,会执行 logDTOList.forEach(createLogFunction);
也就等于啥都没执行呗
所以原方法异常时,是不会记录失败日志的对吧
from log-record.
第一眼 看成是 logDTOList = new ArrayList<>(logDtoMap.size()); 了,后面再看这段代码,惯性一直以为是logDtoMap.size()
哈哈哈😆
from log-record.
Related Issues (20)
- 传入自定义线程池 HOT 1
- @OperationLog的success参数建议 HOT 1
- 你的mac地址怎么获取的 HOT 1
- 使用mybatisplus动态表名插件和aop有冲突 HOT 1
- 支持一下作者,开源不易,我也做日志库的,作者可以帮我宣传一下吗?
- 自定义 log-record.diff-msg-format 结果错误 HOT 3
- 关于 @LogRecordDiffObject 和 @LogRecordDiffField 的一些建议 HOT 3
- 关于自定义 success、exception 和全局异常处理的顺序问题 HOT 1
- 新增常用公共函数和可序列化对象注解的建议 HOT 1
- 请教一个小问题😂 HOT 11
- @OperationLog嵌套线程上下文被清除
- Java17启动报错,改为jdk1.8就没问题 HOT 3
- 请问可以自动获取controller层的request参数吗
- Null return value from advice does not match primitive return type for: public abstract boolean cn.monitor4all.logRecord.service.IOperationLogGetService.createLog(cn.monitor4all.logRecord.bean.LogDTO) HOT 1
- 最新版本的拉不下来 log-record-core包没有上传 HOT 1
- springboot3 无法通过 maven 下载jar 包 HOT 4
- 自定义上下文空字符串影响多个@OperationLog的定义顺序 HOT 1
- 文档中描写有问题 HOT 1
- 编码文件格式问题 HOT 2
- _DIFF()时getDeclaredFields()获取不到父类字段问题 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from log-record.