Commit a01fc5b7 by Olivier Bourgain Committed by Spencer Gibb

Fix check then act issue (#2160)

parent 481e3122
...@@ -140,7 +140,7 @@ public class FormBodyWrapperFilter extends ZuulFilter { ...@@ -140,7 +140,7 @@ public class FormBodyWrapperFilter extends ZuulFilter {
private HttpServletRequest request; private HttpServletRequest request;
private byte[] contentData; private volatile byte[] contentData;
private MediaType contentType; private MediaType contentType;
...@@ -183,6 +183,9 @@ public class FormBodyWrapperFilter extends ZuulFilter { ...@@ -183,6 +183,9 @@ public class FormBodyWrapperFilter extends ZuulFilter {
} }
private synchronized void buildContentData() { private synchronized void buildContentData() {
if (this.contentData != null) {
return;
}
try { try {
MultiValueMap<String, Object> builder = RequestContentDataExtractor.extract(this.request); MultiValueMap<String, Object> builder = RequestContentDataExtractor.extract(this.request);
FormHttpOutputMessage data = new FormHttpOutputMessage(); FormHttpOutputMessage data = new FormHttpOutputMessage();
...@@ -192,8 +195,9 @@ public class FormBodyWrapperFilter extends ZuulFilter { ...@@ -192,8 +195,9 @@ public class FormBodyWrapperFilter extends ZuulFilter {
FormBodyWrapperFilter.this.formHttpMessageConverter.write(builder, this.contentType, data); FormBodyWrapperFilter.this.formHttpMessageConverter.write(builder, this.contentType, data);
// copy new content type including multipart boundary // copy new content type including multipart boundary
this.contentType = data.getHeaders().getContentType(); this.contentType = data.getHeaders().getContentType();
this.contentData = data.getInput(); byte[] input = data.getInput();
this.contentLength = this.contentData.length; this.contentLength = input.length;
this.contentData = input;
} }
catch (Exception e) { catch (Exception e) {
throw new IllegalStateException("Cannot convert form data", e); throw new IllegalStateException("Cannot convert form data", e);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment