Hedging: Fixes rare NullRefreneceException in Headers Clone#5096
Closed
NaluTripician wants to merge 10 commits intomasterfrom
Closed
Hedging: Fixes rare NullRefreneceException in Headers Clone#5096NaluTripician wants to merge 10 commits intomasterfrom
NaluTripician wants to merge 10 commits intomasterfrom
Conversation
kirankumarkolli
previously approved these changes
Mar 28, 2025
Pilchie
reviewed
Mar 28, 2025
| foreach (string key in this.CosmosMessageHeaders.AllKeys()) | ||
| { | ||
| clone.Add(key, this.CosmosMessageHeaders.Get(key)); | ||
| string value = this.CosmosMessageHeaders.Get(key); |
Member
There was a problem hiding this comment.
Is it expected that there be nulls in there? Instead of (or as well as) this should we be investigating how the null got in there?
Member
There was a problem hiding this comment.
I assumed that it's a concurrency issue, otherwise +1
Member
There was a problem hiding this comment.
What concurrency issue? Someone is writing to the headers collection on one thread while we're reading? That's not safe.
Contributor
Author
|
Fixed in: #5189 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Template
Description
There is a rare case where a
NullReferenceExceptioncan occur when cloning headers in theHeadersclass, in request hedging scenarionsThis pull request introduces a null check in the
Clonemethod of theHeadersclass and adds new unit tests to verify the cloning functionality, including handling of null values.Enhancements to
Headersclass cloning:Microsoft.Azure.Cosmos/src/Headers/Headers.cs: Added a null check in theClonemethod to ensure that headers with null values are not added to the cloned headers.New unit tests for
Headersclass:Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/HeadersTests.cs: AddedTestHeadersCloneto verify that all keys and values are correctly cloned.Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/HeadersTests.cs: AddedTestNullHeadersCloneto ensure that headers with null values are handled correctly during cloning.Type of change
Please delete options that are not relevant.
Closing issues
To automatically close an issue: closes #5093