From 08eeaacdbfcad4c104171be3526ac4c8aac88b29 Mon Sep 17 00:00:00 2001 From: zhouhao Date: Tue, 4 Jul 2023 18:19:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=B8=8A=E4=B8=8B?= =?UTF-8?q?=E6=96=87=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aop/ReactiveAopAccessLoggerSupport.java | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/ReactiveAopAccessLoggerSupport.java b/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/ReactiveAopAccessLoggerSupport.java index 17ddec8f2..b1f94673b 100644 --- a/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/ReactiveAopAccessLoggerSupport.java +++ b/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/ReactiveAopAccessLoggerSupport.java @@ -67,27 +67,23 @@ public class ReactiveAopAccessLoggerSupport extends StaticMethodMatcherPointcutA }); } - private Mono currentRequestInfo() { - return Mono - .deferContextual(context -> { - if (context.hasKey(RequestInfo.class)) { - RequestInfo info = context.get(RequestInfo.class); - ReactiveLogger.log(context, ctx -> info.setContext(new HashMap<>(ctx))); - return Mono.just(info); - } - return Mono.empty(); - }); + private Mono currentRequestInfo(ContextView context) { + if (context.hasKey(RequestInfo.class)) { + RequestInfo info = context.get(RequestInfo.class); + ReactiveLogger.log(context, ctx -> info.setContext(new HashMap<>(ctx))); + return Mono.just(info); + } + return Mono.empty(); } protected Flux wrapFluxResponse(Flux flux, AccessLoggerInfo loggerInfo) { return Flux.deferContextual(ctx -> this - .currentRequestInfo() + .currentRequestInfo(ctx) .doOnNext(loggerInfo::putAccessInfo) .then(beforeRequest(loggerInfo)) .thenMany(flux) .doOnError(loggerInfo::setException) - .doFinally(signal -> completeRequest(loggerInfo, ctx))) - .contextWrite(ReactiveLogger.start("accessLogId", loggerInfo.getId())); + .doFinally(signal -> completeRequest(loggerInfo, ctx))); } private Mono beforeRequest(AccessLoggerInfo loggerInfo) {