Fixed: streaming large content cause out of memory exception.

(OFBIZ-10133)

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

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1821054 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jacques Le Roux
2018-01-13 09:37:38 +00:00
parent 67d62f9ad6
commit e45a869e17
@@ -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);
}