You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement smart retry with proper duplicate byte skipping for structured messages
Enhanced StorageContentValidationDecoderPolicy to properly handle retries from arbitrary mid-segment offsets by detecting and skipping duplicate bytes.
Changes to StorageContentValidationDecoderPolicy:
- Added getResponseStartOffset() to parse Content-Range header and determine retry offset
- Enhanced DecoderState to track currentResponseStartOffset and currentResponseBytesRead
- Modified decodeStream() to calculate absolute buffer offsets and skip duplicate bytes
- When a retry occurs, the policy now:
1. Detects the starting offset from Content-Range header
2. Calculates which bytes in each buffer are duplicates
3. Skips duplicate bytes before feeding to decoder
4. Only processes new bytes, maintaining continuous decoder state
This implementation allows the decoder to receive a continuous stream of non-duplicate encoded bytes, even when retries occur from arbitrary offsets. The decoder doesn't need to be aware of retries - the policy handles all offset calculations and duplicate filtering.
Compatible with range downloads and works for arbitrary mid-segment offset resumption.
Co-authored-by: gunjansingh-msft <[email protected]>
Copy file name to clipboardExpand all lines: sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/policy/StorageContentValidationDecoderPolicy.java
+72-5Lines changed: 72 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -63,6 +63,10 @@ public Mono<HttpResponse> process(HttpPipelineCallContext context, HttpPipelineN
0 commit comments