Skip to content
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

[Bug]: ResilienceProperties works incorrectly when the value requested by a key is null #2299

Open
iliar-turdushev opened this issue Sep 20, 2024 · 1 comment · May be fixed by #2300
Open
Labels

Comments

@iliar-turdushev
Copy link

iliar-turdushev commented Sep 20, 2024

Describe the bug

Methods TryGetValue and GetValue work incorrectly when the requested value is null. Specifically, TryGetValue returns false meaning it cannot find the key, and GetValue returns a value specified as a default value if the key was not found:

var key = new ResiliencePropertyKey<string?>("dummy");
var props = new ResilienceProperties();
props.Set(key, null);

props.TryGetValue(key, out var val) --> will return false, val will have null value though
props.GetValue(key, "default") --> will return a string "default", although the real value is null

Expected behavior

ResilienceProperties must return correct results even if a value being requested is null, in particular:

props.TryGetValue(key, out var val) --> must return true and val must be null
props.GetValue(key, "default") --> must return null

Actual behavior

No response

Steps to reproduce

No response

Exception(s) (if any)

No response

Polly version

8.4.1

.NET Version

net6.0 net8.0

Anything else?

No response

iliar-turdushev added a commit to iliar-turdushev/Polly that referenced this issue Sep 20, 2024
Adds logic handling a case when the value being requested is null
@iliar-turdushev
Copy link
Author

I've opened a PR #2300 to fix this issue. Could you, please, review it? Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant