You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We then call Foo.dispose() before the async part of doStuff as finished
This exact pattern varies in our codebase, but it can be hit anytime we are adding to a disposable array inside of an async method (it can be hit sync too if you introduce a weird calling pattern)
Proposed fix
To fix this, I propose encapsulating the idea of set of disposables in a class that manages an array of disposables. If an instance of this class is disposed, any attempts to register a new disposable with it would have no effect and the registered object would be disposed
We basically already have this, but the current class is only intended to be used as base class. My proposal is to extract and expose a new value class from the current Disposable class
The text was updated successfully, but these errors were encountered:
Bug
Consider the following class that tries to manage a list of disposables:
This can leak a disposable in the following case:
new Foo()
Foo.dispose()
before the async part ofdoStuff
as finishedThis exact pattern varies in our codebase, but it can be hit anytime we are adding to a disposable array inside of an async method (it can be hit sync too if you introduce a weird calling pattern)
Proposed fix
To fix this, I propose encapsulating the idea of set of disposables in a class that manages an array of disposables. If an instance of this class is disposed, any attempts to register a new disposable with it would have no effect and the registered object would be disposed
We basically already have this, but the current class is only intended to be used as base class. My proposal is to extract and expose a new value class from the current
Disposable
classThe text was updated successfully, but these errors were encountered: