akamsteeg / AtleX.HaveIBeenPwned

A fully async .NET Standard client library for the API of HaveIBeenPwned.com
https://www.nuget.org/packages/AtleX.HaveIBeenPwned/
MIT License
5 stars 0 forks source link

HaveIBeenPwnedClient must not dispose an injected IHaveIBeenPwnedClient #11

Closed akamsteeg closed 5 years ago

akamsteeg commented 5 years ago

In #6 we fixed that the HttpHaveIBeenPwnedClient does not dispose an injected HttpClient because it's not the owner of it. Disposing it is the responsibility of the caller, because they created the HttpClient and might be using it after disposing of HttpHaveIBeenPwnedClient.

However, HaveIBeenPwnedClient always disposes its injected IHaveIBeenPwnedClient and that's incorrect in the same way: The creator is responsible for cleaning up too.

So, we must adapt HaveIBeenPwnedClient to only dispose of the IHaveIBeenPwnedClient used when it was not injected into the constructor.