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

CancellationTokenSource in RpcClient not disposed. It would result in a leaked Timer object. #964

Open
timaiv opened this issue Aug 2, 2023 · 0 comments

Comments

@timaiv
Copy link

timaiv commented Aug 2, 2023

CancellationTokenSource should be disposed.
Since we use timer (CancelAfter) it must be disposed properly.

https://github.com/Nethereum/Nethereum/blob/d1edf622614fb935ac8809a4b344b1b94d3a1820/src/Nethereum.JsonRpc.RpcClient/RpcClient.cs#L116C17-L117C1

https://stackoverflow.com/questions/6960520/when-to-dispose-cancellationtokensource
http://web.archive.org/web/20160203062224/http://blogs.msdn.com/b/pfxteam/archive/2012/03/25/10287435.aspx
https://github.com/dotnet/runtime/blob/aaab1701493d2e3bf392cac79f95a167039c9250/src/libraries/System.Private.CoreLib/src/System/Threading/CancellationTokenSource.cs#L427
https://github.com/dotnet/runtime/blob/aaab1701493d2e3bf392cac79f95a167039c9250/src/libraries/System.Private.CoreLib/src/System/Threading/CancellationTokenSource.cs#L539

Expected Behavior

using var cancellationTokenSource = new CancellationTokenSource();
or
cancellationTokenSource.Dispose() (in try finally)

Current Behavior

var cancellationTokenSource = new CancellationTokenSource();
Dispose missing.

Context (Environment)

4.15.2

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

No branches or pull requests

1 participant