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

Fix unhandled KeyNotFoundException in RequestReplyCorrelator #4743

Merged
merged 1 commit into from
Oct 15, 2021

Conversation

mconnew
Copy link
Member

@mconnew mconnew commented Oct 14, 2021

Fixes #4301

@@ -45,13 +44,12 @@ T IRequestReplyCorrelator.Find<T>(Message reply, bool remove)
UniqueId relatesTo = GetRelatesTo(reply);
Type stateType = typeof(T);
Key key = new Key(relatesTo, stateType);
T value;
T value = (T)_states[key];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this would have been a potential issue before, but Dictionary would throw here if the key wasn't found, resulting in an exception here instead of returning null. Unless that was the intent of this method. In which case, Hashtable doesn't do that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's exactly the issue I'm fixing 😄. On NetFx it uses Hashtable. The change to Dictionary caused an uncaught exception thrown right here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's right there in the title and everything. Doh! 🤦‍♂️

@mconnew mconnew merged commit 74dbe9b into dotnet:main Oct 15, 2021
@mconnew mconnew deleted the Issue4301 branch October 11, 2023 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TaskScheduler UnobservedTaskException on long run of WCF 4.7.0 on .NetCore 3.1 (Win)
2 participants