-
Notifications
You must be signed in to change notification settings - Fork 524
Hedging: Fixes rare NullRefreneceException in Headers Clone #5096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| foreach (string key in this.CosmosMessageHeaders.AllKeys()) | ||
| { | ||
| clone.Add(key, this.CosmosMessageHeaders.Get(key)); | ||
| string value = this.CosmosMessageHeaders.Get(key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assumed that it's a concurrency issue, otherwise +1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What concurrency issue? Someone is writing to the headers collection on one thread while we're reading? That's not safe.
|
Fixed in: #5189 |
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