Convert to Hex only on Encoding.UTF8.GetString possible exceptions #2954
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.
Issue #2913
Under high memory pressure, OutOfMemory exceptions can occure randomly on every line of code that allocate memory like in native
Encoding.UTF8.GetString
used by the tried call toFormat.GetString(span);
Redis value conversion to string should not convert string in hex value on all possible exception but only when value is not a valid UTF8 byte array....
For this the catch will catch only possible exceptions thrown by
Encoding.UTF8.GetString
, this should not change the conversion behavior but will fix bad results in case ofOutOfMemory
exceptions or other not expected exceptions.Encoding.UTF8.GetString
from Microsoft documentation:ArgumentException
The byte array contains invalid Unicode code points.
ArgumentNullException
bytes is null.
DecoderFallbackException
A fallback occurred (for more information, see Character Encoding in .NET)