Reuse InputStream in ResourceRegionHttpMessageConverter
The converter now tries to keep reading from the same InputStream which should be possible with ordered and non-overlapping regions. When necessary the InputStream is re-opened. Closes gh-24214
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -170,7 +170,7 @@ public abstract class StreamUtils {
|
||||
}
|
||||
|
||||
long bytesToCopy = end - start + 1;
|
||||
byte[] buffer = new byte[StreamUtils.BUFFER_SIZE];
|
||||
byte[] buffer = new byte[(int) Math.min(StreamUtils.BUFFER_SIZE, bytesToCopy)];
|
||||
while (bytesToCopy > 0) {
|
||||
int bytesRead = in.read(buffer);
|
||||
if (bytesRead == -1) {
|
||||
|
||||
Reference in New Issue
Block a user