Fix null reference exception in CacheValues.For when building the CompositeStringStringKey #17024
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.
Prerequisites
Fixes #16753
Bug summary
CacheValues.For
accepts nullable string culture and segment parameters but only performs an empty string check on them, not a null or empty check. This results in an exception because it then attempts to create aCompositeStringStringKey
with the culture and segment but this object doesn't accept null arguments.Description
As noted on IPropertyValue, null value means invariant.
But as we need an actual string value to build a CompositeStringStringKey, we need to convert null to empty
Testing
Make sure (invariant) (published) content still behaves correctly in multi culture/segment scenarios.