Spring Boot 2包括堆栈Trace,当未给出跟踪参数时



从弹簧启动1.5.12升级到2.0.1后,即使在url中未指定跟踪参数" trace",系统即使在错误的情况下都包含一个stacktrace(或错误地指定了无效的值(。

我已经配置了

server.error.include-stacktrace = on-trace-param

在我的application.properties中。

当我调用我的应用程序时,会通过http://localhost/myapp返回系统返回填充跟踪。

当我通过http://localhost/myApp?trace = false时,当我调用它时。

当我通过http://localhost/myapp?trace = hugo tos and http://http://localhost/myApp?trace = true = true。

时。

在Spring Boot 1下不是这种情况。在那里,系统确实仅在一个指定的跟踪= True时才包含堆栈跟踪,这是预期的行为。

这种行为是否从版本1更改为2?

ciao,迈克尔

这是Springboot2.0.3

中的代码
protected boolean getTraceParameter(HttpServletRequest request) {
    String parameter = request.getParameter("trace");
    return !"false".equalsIgnoreCase(parameter);
}

在springboot2.1

protected boolean getTraceParameter(HttpServletRequest request) {
    String parameter = request.getParameter("trace");
    if (parameter == null) {
        return false;
    }
    return !"false".equalsIgnoreCase(parameter);
}

将Springboot版本升级到2.1,以解决问题

最新更新