Skip to content

Commit 940f2e6

Browse files
committed
chore(log/aop): 日志后置处理改为无返回值方法
1 parent f0559ee commit 940f2e6

File tree

1 file changed

+5
-7
lines changed
  • continew-starter-log/continew-starter-log-aop/src/main/java/top/continew/starter/log/aop/aspect

1 file changed

+5
-7
lines changed

continew-starter-log/continew-starter-log-aop/src/main/java/top/continew/starter/log/aop/aspect/LogAspect.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,10 @@ public void doBefore() {
7171
* 处理请求后执行 - 正常返回
7272
*
7373
* @param joinPoint 切点
74-
* @param result 结果
7574
*/
76-
@AfterReturning(pointcut = "pointcutService()", returning = "result")
77-
public void afterReturning(JoinPoint joinPoint, Object result) {
78-
handleAfterCompletion(joinPoint, null, result);
75+
@After(value = "pointcutService()")
76+
public void afterAdvice(JoinPoint joinPoint) {
77+
handleAfterCompletion(joinPoint, null);
7978
}
8079

8180
/**
@@ -86,7 +85,7 @@ public void afterReturning(JoinPoint joinPoint, Object result) {
8685
*/
8786
@AfterThrowing(pointcut = "pointcutService()", throwing = "ex")
8887
public void afterThrowing(JoinPoint joinPoint, Exception ex) {
89-
handleAfterCompletion(joinPoint, ex, null);
88+
handleAfterCompletion(joinPoint, ex);
9089
}
9190

9291
/**
@@ -96,7 +95,7 @@ public void afterThrowing(JoinPoint joinPoint, Exception ex) {
9695
* @param ex 异常
9796
* @param result 返回结果
9897
*/
99-
private void handleAfterCompletion(JoinPoint joinPoint, Exception ex, Object result) {
98+
private void handleAfterCompletion(JoinPoint joinPoint, Exception ex) {
10099
try {
101100
Instant endTime = Instant.now();
102101
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
@@ -142,7 +141,6 @@ private void handleAfterCompletion(JoinPoint joinPoint, Exception ex, Object res
142141
logModule(finishedLogRecord, methodLog, classLog);
143142
}
144143
logDao.add(finishedLogRecord);
145-
146144
} catch (Exception e) {
147145
log.error("Logging http log occurred an error: {}.", e.getMessage(), e);
148146
} finally {

0 commit comments

Comments
 (0)