Set traceRequestBody to false by default (#3439)

traceRequestBody requires the body to be buffered which reduces performance and can be problematic, such as when used in combination with `zuul.use-filter=true` and `zuul.servlet-path=/` See https://github.com/spring-cloud/spring-cloud-netflix/issues/3418

traceRequestBody should only be set when logging the request body is actually necessary.
This commit is contained in:
Craig Andrews
2019-03-19 14:51:42 -04:00
committed by Spencer Gibb
parent 77b8965e29
commit 52e4f5ea59
2 changed files with 10 additions and 4 deletions

View File

@@ -137,7 +137,7 @@ public class ZuulProperties {
/**
* Flag to say that request bodies can be traced.
*/
private boolean traceRequestBody = true;
private boolean traceRequestBody = false;
/**
* Flag to say that path elements past the first semicolon can be dropped.

View File

@@ -130,7 +130,9 @@ public class ProxyRequestHelperTests {
RequestContext context = RequestContext.getCurrentContext();
context.setRequest(request);
ProxyRequestHelper helper = new ProxyRequestHelper(new ZuulProperties());
ZuulProperties zuulProperties = new ZuulProperties();
zuulProperties.setTraceRequestBody(true);
ProxyRequestHelper helper = new ProxyRequestHelper(zuulProperties);
assertThat(helper.shouldDebugBody(context)).as("shouldDebugBody wrong").isTrue();
}
@@ -139,7 +141,9 @@ public class ProxyRequestHelperTests {
public void shouldDebugBodyNullRequest() throws Exception {
RequestContext context = RequestContext.getCurrentContext();
ProxyRequestHelper helper = new ProxyRequestHelper(new ZuulProperties());
ZuulProperties zuulProperties = new ZuulProperties();
zuulProperties.setTraceRequestBody(true);
ProxyRequestHelper helper = new ProxyRequestHelper(zuulProperties);
assertThat(helper.shouldDebugBody(context)).as("shouldDebugBody wrong").isTrue();
}
@@ -151,7 +155,9 @@ public class ProxyRequestHelperTests {
RequestContext context = RequestContext.getCurrentContext();
context.setRequest(request);
ProxyRequestHelper helper = new ProxyRequestHelper(new ZuulProperties());
ZuulProperties zuulProperties = new ZuulProperties();
zuulProperties.setTraceRequestBody(true);
ProxyRequestHelper helper = new ProxyRequestHelper(zuulProperties);
assertThat(helper.shouldDebugBody(context)).as("shouldDebugBody wrong").isTrue();
}