-
Notifications
You must be signed in to change notification settings - Fork 186
Closed
Labels
bugAdded to issues that describes SDK bugAdded to issues that describes SDK bugdontstaleMark issues not to be removed by stalebotMark issues not to be removed by stalebot
Description
- I have checked that the [SDK documentation][sdk-docs] doesn't solve my issue.
- I have checked that the [API documentation][api-docs] doesn't solve my issue.
- I have searched the [Box Developer Forums][dev-forums] and my issue isn't already reported (or if it has been reported, I have attached a link to it, for reference).
- I have searched [Issues in this repo][github-repo] and my issue isn't already reported.
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
Metadata
Metadata
Labels
bugAdded to issues that describes SDK bugAdded to issues that describes SDK bugdontstaleMark issues not to be removed by stalebotMark issues not to be removed by stalebot