-
Notifications
You must be signed in to change notification settings - Fork 458
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
TypedFactory facility disposes singletons created during factory lifetime #134
Comments
As @ivan-danilov mentioned in #61:
|
This obviously isn't just a problem for singleton components created inside a factory, but all other non-transient lifestyles will get prematurely disposed components. I think It sounds like the fix would be for transient components created inside the factory to be tracked by the factory's release policy, and for everything else to get the parent I don't know exactly how this would be implemented because If the factory is a different lifestyle (i.e. scoped) then tracking transients against the factory is a good idea to make sure they always get cleaned up, however what about components of the same lifestyle, should scoped components also get tracked against the factory or leave them for normal lifestyle decommission? I think we need to decide what the behaviour of this facility should be on components it creates before trying to make a fix. /cc @ivan-danilov @jberezanski @xlegalles @IanYates @petr-k @ghost @hammett @bindu-purhar @Fir3pho3nixx (unsub if you aren't interested anymore) |
My experimental PR is a proposal to walk through the flow of information we need in the TypedFactoryInterceptor by exposing a CreationContext using reflection(bad I know!) on the component, this also gives the SingletonLifestyleManager the ability to dump the creation context for disposals(ultimately when the container is disposed). Based on those two signals the TypedFactoryInterceptor can then inspect the existance of the CreationContext and then decide whether to dispose a singleton correctly. Nowhere near a solution yet, but hopefully a template for discussion. |
Maybe I'm completely misunderstanding something, but this isn't a problem for the |
@jonorossi - I will be honest I am not sure I follow. I am not clear on your comments about component "ownership". I feel like I am missing something obvious. |
The main point I was making in #134 (comment) is that this problem isn't isolated to singletons, other non-transient lifestyles get caught up with this mess of a different release policy. I was hoping to initiate a discussion on how people are using this facility and how those lifestyles should be handled before trying to work out how to fix it. Does that help make my comments any clearer? |
@jonorossi - Yes, I think I follow you. I can play around with these release policies, to try and validate this approach. |
@jonorossi Calling A factory should not dictate lifetime of its products - their respective lifetimes should work as usual. After all, when you call P.S. I use term |
Is it by chance fixed by #439 ? cc @jnm2 @jonorossi |
Yes, I do believe it is! |
Thanks, I'll close this issue. I'll leave it to you guys to determine if those unit tests add value on top of the tests added in #439. |
I guess it was my mistake to make a PR with failing tests without accompanying issue in #61
In short, some instances registered with Singleton lifestyle could be disposed too early and later throw ObjectDisposedException. Like here
The text was updated successfully, but these errors were encountered: