Fixed: streaming large content cause out of memory exception.
No functional change in trunk
Slightly improves formatting in streamContent() in trunk.
Uses the same code in R16, notably for setting
byte[] buffer = new byte[bufferSize];
that guarantee no issues, and using try-with-ressource
@@ -1092,10 +1092,8 @@ public final class UtilHttp {
int bufferSize = EntityUtilProperties.getPropertyAsInteger("content", "stream.buffersize", 8192);
byte[] buffer = new byte[bufferSize];
int read = 0;
- try (
- BufferedOutputStream bos = new BufferedOutputStream(out, bufferSize);
- BufferedInputStream bis = new BufferedInputStream(in, bufferSize);
- ) {
+ try (BufferedOutputStream bos = new BufferedOutputStream(out, bufferSize);
+ BufferedInputStream bis = new BufferedInputStream(in, bufferSize)) {
while ((read = bis.read(buffer, 0, buffer.length)) != -1) {
bos.write(buffer, 0, read);
}
