- byte[] additional = client.readBytes();
- arrayCopy(additional, 0, buffer, bufferedByteCount, additional.length);
- bufferedByteCount += additional.length;
+ byte[] additional = new byte[buffer.length - bufferedByteCount];
+ int additionalLength = client.readBytes(additional);
+ arrayCopy(additional, 0, buffer, bufferedByteCount, additionalLength);
+ bufferedByteCount += additionalLength;