Skip to content

Commit

Permalink
Fixed: readAllBytes fails with BUFFER_SIZE == -1
Browse files Browse the repository at this point in the history
  • Loading branch information
mkarg committed Jun 9, 2023
1 parent 42078bd commit fa2cbd2
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public static String readFromAsString(InputStream in, MediaType type) throws IOE
*/
public static String readFromAsString(Reader reader) throws IOException {
StringBuilder sb = new StringBuilder();
char[] c = new char[BUFFER_SIZE];
char[] c = new char[BUFFER_SIZE == -1 ? 16384 : BUFFER_SIZE];
int l;
while ((l = reader.read(c)) != -1) {
sb.append(c, 0, l);
Expand All @@ -184,6 +184,7 @@ public static String readFromAsString(Reader reader) throws IOException {
* TODO Replace in Jersey 4.0, as the sole difference to OpenJDK is working around a bug in the input stream.
*/
private static byte[] readAllBytes(InputStream inputStream) throws IOException {
int BUFFER_SIZE = ReaderWriter.BUFFER_SIZE == -1 ? 16384 : ReaderWriter.BUFFER_SIZE;
List<byte[]> bufs = null;
byte[] result = null;
int total = 0;
Expand Down

0 comments on commit fa2cbd2

Please sign in to comment.