Skip to content

Commit

Permalink
Fixes bug in buffered upload where data would be uploaded incorrectly…
Browse files Browse the repository at this point in the history
… if data did not fit exactly in the buffers (#12832)
  • Loading branch information
gapra-msft authored Jul 7, 2020
1 parent b730543 commit 3d49736
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,11 @@ public Flux<BufferAggregator> write(ByteBuffer buf) {
// We will overflow the current buffer and require another one.
// Duplicate and adjust the window of buf so that we fill up currentBuf without going out of bounds.
ByteBuffer duplicate = buf.duplicate();
duplicate.limit(buf.position() + (int) this.currentBuf.remainingCapacity());
int newLimit = buf.position() + (int) this.currentBuf.remainingCapacity();
duplicate.limit(newLimit);
this.currentBuf.append(duplicate);
// Adjust the window of original buffer to represent remaining part.
buf.position(buf.position() + (int) this.currentBuf.remainingCapacity());
buf.position(newLimit);

result = Flux.just(this.currentBuf);

Expand Down

0 comments on commit 3d49736

Please sign in to comment.