MultipartHttpMessageWriter consumes source once only
The previous fix #09f1f7 did not actually address the issue but only
moved it further down, so instead of the subscribe(), it was consuming
it inside the MultipartHttpMessageWriter#write method which returned
this.body.then(), and then again for the actual request body writing.
In this commit MultipartHttpMessageWriter#write returns Mono.empty()
since we don't actually want to write the part content from there, but
only want to access it as soon as it is availabele, for writing to
the request body.
Issue: SPR-16402
@ -269,13 +269,18 @@ public class MultipartHttpMessageWriter implements HttpMessageWriter<MultiValueM
@@ -269,13 +269,18 @@ public class MultipartHttpMessageWriter implements HttpMessageWriter<MultiValueM
@ -353,7 +358,9 @@ public class MultipartHttpMessageWriter implements HttpMessageWriter<MultiValueM
@@ -353,7 +358,9 @@ public class MultipartHttpMessageWriter implements HttpMessageWriter<MultiValueM
returnMono.error(newIllegalStateException("Multiple calls to writeWith() not supported"));
// We don't actually want to write (just save the body Flux)
returnMono.empty();
}
privateDataBuffergenerateHeaders(){
@ -387,8 +394,7 @@ public class MultipartHttpMessageWriter implements HttpMessageWriter<MultiValueM
@@ -387,8 +394,7 @@ public class MultipartHttpMessageWriter implements HttpMessageWriter<MultiValueM
@Override
publicMono<Void>setComplete(){
return(this.body!=null?this.body.then():
Mono.error(newIllegalStateException("Body has not been written yet")));