Use DataBufferUtils.write in DefaultFilePart.transferTo
This commit makes sure that in DefaultMultipartMessageReader's
DefaultFilePart, the file is not closed before all bytes are written,
by using DataBufferUtils.write (see c1b6885191d6a50347aeaa14da994f0db88f26fe).
The commit also improves on the logging of the
DefaultMultipartMessageReader.
Closes gh-23130
@ -100,10 +95,6 @@ public class DefaultMultipartMessageReader extends LoggingCodecSupport implement
@@ -100,10 +95,6 @@ public class DefaultMultipartMessageReader extends LoggingCodecSupport implement
returnFlux.error(newCodecException("No multipart boundary found in Content-Type: \""+
@ -148,8 +139,10 @@ public class DefaultMultipartMessageReader extends LoggingCodecSupport implement
@@ -148,8 +139,10 @@ public class DefaultMultipartMessageReader extends LoggingCodecSupport implement
logger.trace("Found first boundary at "+endIdx+" in "+toString(dataBuffer));
}
logger.trace(
"Found last byte of first boundary ("+toString(boundary)
+") at "+endIdx);
}
returnMono.just(slice);
}
else{
@ -188,14 +181,14 @@ public class DefaultMultipartMessageReader extends LoggingCodecSupport implement
@@ -188,14 +181,14 @@ public class DefaultMultipartMessageReader extends LoggingCodecSupport implement
}
}
if(logger.isTraceEnabled()){
logger.trace("Part data: "+toString(dataBuffer));
}
intendIdx=HEADER_MATCHER.match(dataBuffer);
HttpHeadersheaders;
DataBufferbody;
if(endIdx>0){
if(logger.isTraceEnabled()){
logger.trace("Found last byte of part header at "+endIdx);
@ -204,6 +197,9 @@ public class DefaultMultipartMessageReader extends LoggingCodecSupport implement
@@ -204,6 +197,9 @@ public class DefaultMultipartMessageReader extends LoggingCodecSupport implement
headers=toHeaders(headersBuffer);
}
else{
if(logger.isTraceEnabled()){
logger.trace("No header found");
}
headers=newHttpHeaders();
body=DataBufferUtils.retain(dataBuffer);
}
@ -252,16 +248,6 @@ public class DefaultMultipartMessageReader extends LoggingCodecSupport implement
@@ -252,16 +248,6 @@ public class DefaultMultipartMessageReader extends LoggingCodecSupport implement
@ -368,10 +354,6 @@ public class DefaultMultipartMessageReader extends LoggingCodecSupport implement
@@ -368,10 +354,6 @@ public class DefaultMultipartMessageReader extends LoggingCodecSupport implement
@ -385,23 +367,9 @@ public class DefaultMultipartMessageReader extends LoggingCodecSupport implement
@@ -385,23 +367,9 @@ public class DefaultMultipartMessageReader extends LoggingCodecSupport implement
@ -145,6 +150,34 @@ public class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTes
@@ -145,6 +150,34 @@ public class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTes
@ -217,6 +250,21 @@ public class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTes
@@ -217,6 +250,21 @@ public class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTes