Skip to content

Commit 899bfb4

Browse files
Fix incomplete data detection to handle all decoder exceptions
Extended the incomplete data detection logic to catch ALL types of insufficient data errors from the decoder, not just "not long enough" messages. The decoder throws different incomplete data errors: - "Content not long enough" - when parsing message header (13 bytes needed) - "Segment header is incomplete" - when parsing segment header (10 bytes needed) - "Segment footer is incomplete" - when parsing segment footer (8 bytes for CRC64) - "Message footer is incomplete" - when parsing message footer (8 bytes for CRC64) Previous fix only caught "not long enough", causing failures when interruptions occurred while parsing segments/footers. Updated exception handling to check for both: - "not long enough" (header parsing) - "is incomplete" (segment/footer parsing) This ensures partial data is preserved in pending buffer for ALL incomplete data scenarios, allowing smart retry to properly accumulate bytes across interruptions regardless of where in the message structure the interruption occurs. Addresses the "Unexpected segment number" error that occurred when segments were split across retries. Co-authored-by: gunjansingh-msft <[email protected]>
1 parent ec7de83 commit 899bfb4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/policy/StorageContentValidationDecoderPolicy.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ private Flux<ByteBuffer> decodeStream(Flux<ByteBuffer> encodedFlux, DecoderState
116116
}
117117
} catch (IllegalArgumentException e) {
118118
// Handle decoder exceptions - check if it's due to incomplete data
119-
if (e.getMessage() != null && e.getMessage().contains("not long enough")) {
119+
String errorMsg = e.getMessage();
120+
if (errorMsg != null && (errorMsg.contains("not long enough") || errorMsg.contains("is incomplete"))) {
120121
// Not enough data to decode yet - preserve all data in pending buffer
121122
state.updatePendingBuffer(dataToProcess);
122123

0 commit comments

Comments
 (0)