Commit 107ee8c
Fix retry offset calculation - use totalEncodedBytesProcessed to request new bytes
The root cause was using getRetryOffset() (which subtracts pending bytes) to determine what to request from the server. This caused requesting bytes we already have in the pending buffer, creating duplicates.
The correct logic:
- totalEncodedBytesProcessed tracks ALL bytes we've received from the server (including those in pending)
- pending buffer holds bytes waiting for more data to complete a structure
- When retrying, we need to request NEW bytes starting from totalEncodedBytesProcessed
- The pending buffer will be combined with new bytes in the policy's decodeStream method
Example:
1. Request bytes=0-, get byte 0, totalEncodedBytesProcessed=1, pending=[0]
2. IOException, retry requesting bytes=1- (starting from totalEncodedBytesProcessed=1)
3. Get byte 1, combine with pending [0] + [1] = [0,1], totalEncodedBytesProcessed=2
4. Still insufficient, pending=[0,1], continue...
This ensures:
- No duplicate bytes from server
- Pending buffer accumulates across retries
- Decoder receives continuous byte stream
- Smart retry resumes from correct offset
Addresses comment #2499104452.
Co-authored-by: gunjansingh-msft <[email protected]>1 parent 3b0fa7b commit 107ee8c
File tree
1 file changed
+4
-3
lines changed- sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized
1 file changed
+4
-3
lines changedLines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1407 | 1407 | | |
1408 | 1408 | | |
1409 | 1409 | | |
1410 | | - | |
1411 | | - | |
1412 | | - | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
1413 | 1414 | | |
1414 | 1415 | | |
1415 | 1416 | | |
| |||
0 commit comments