【发布时间】:2019-05-17 13:33:18
【问题描述】:
问题
我在Webflux functional programming 之后构建了一个服务器,并将以下代码添加到我的路由器:route(GET("/test/{Id}"), request -> throw new RuntimeException("123"))。
但是当我调用/test/{Id}时,控制台中唯一的错误日志是:
TRACE 153036 --- [ctor-http-nio-7] o.s.w.r.function.server.RouterFunctions : [fc7e809d] Matched org.springframework.web.reactive.function.server.RequestPredicates$$Lambda$827/1369035321@9d8c274
DEBUG 153036 --- [ctor-http-nio-7] org.springframework.web.HttpLogging : [fc7e809d] Resolved [RuntimeException: 123] for HTTP GET /test/job
TRACE 153036 --- [ctor-http-nio-7] org.springframework.web.HttpLogging : [fc7e809d] Encoding [{timestamp=Mon Dec 17 15:34:43 CST 2018, path=/test/123, status=500, error=Internal Server Error, message=123}]
TRACE 153036 --- [ctor-http-nio-7] o.s.w.s.adapter.HttpWebHandlerAdapter : [fc7e809d] Completed 500 INTERNAL_SERVER_ERROR, headers={masked}
TRACE 153036 --- [ctor-http-nio-7] org.springframework.web.HttpLogging : [fc7e809d] Handling completed
没有堆栈跟踪,但是为什么呢?应该是spring或者netty处理的,不是我自定义的代码吧?设置logging.level.org.springframework.web: trace不是解决办法,日志太多了。
这是我目前发现的,但仍然感到困惑:
我查了一下为什么spring mvc有堆栈跟踪,因为tomcat中有一个log.error in try-catch,并且通过调试证明了。
那我想Netty也有这些逻辑吗?其实是has!但是让我感到困惑的是,我无法使用任何断点暂停这个 try-catch 中的代码。
这意味着可能存在一些Mono.onErrorResume 吞噬异常,因此netty 无法捕获任何东西。但我不知道如何调试大型 Mono 来检查根本原因。为什么要吞下去?
【问题讨论】:
-
嗨,@ToffeeLu,你可以:
.doOnError(RuntimeException.class, e -> logger.error(e))
标签: spring spring-boot netty spring-webflux project-reactor