Description of the Issue
The following code is just wrong in AbstractBoxMultipartRequest:
public void writeTo(BufferedSink bufferedSink) throws IOException {
byte[] buffer = new byte[BUFFER_SIZE];
int n = this.inputStream.read(buffer);
int totalWritten = n;
while (n != -1) {
bufferedSink.write(buffer, 0, n);
if (progressListener != null) {
progressListener.onProgressChanged(totalWritten, this.contentLength());
}
totalWritten += n;
n = this.inputStream.read(buffer);
}
}
totalWritten is initialized with n and then incremented with the same n in the cycle, before n is updated.
Steps to Reproduce
- Upload a file larger than 8192 bytes (the upload buffer size) and set a progress listener
- At some point the listener will receive onProgressChanged() with numBytes > totalBytes
Expected Behavior
Progress reporting to be correct and to not exceed the size of the uploaded file
Description of the Issue
The following code is just wrong in AbstractBoxMultipartRequest:
totalWritten is initialized with n and then incremented with the same n in the cycle, before n is updated.
Steps to Reproduce
Expected Behavior
Progress reporting to be correct and to not exceed the size of the uploaded file