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

Use IServiceScopeFactory instead of IHybridServiceScopeFactory for event bus caused the unit test to fail. #1426

Closed
maliming opened this issue Jul 3, 2019 · 6 comments

Comments

@maliming
Copy link
Member

maliming commented Jul 3, 2019

This change(f719bda) caused the unit test to fail.

System.ObjectDisposedException : Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it has already been disposed.
   at Autofac.Core.Lifetime.LifetimeScope.BeginLifetimeScope(Object tag) in C:\projects\autofac\src\Autofac\Core\Lifetime\LifetimeScope.cs:line 133
   at Autofac.Extensions.DependencyInjection.AutofacServiceScopeFactory.CreateScope() in d:\Github\volo\abp\framework\src\Volo.Abp.Autofac\Autofac\Extensions\DependencyInjection\AutofacServiceScopeFactory.cs:line 62
   at Volo.Abp.EventBus.IocEventHandlerFactory.GetHandler() in d:\Github\volo\abp\framework\src\Volo.Abp.EventBus\Volo\Abp\EventBus\IocEventHandlerFactory.cs:line 31
   at Volo.Abp.EventBus.EventBusBase.TriggerHandlerAsync(IEventHandlerFactory asyncHandlerFactory, Type eventType, Object eventData, List`1 exceptions) in d:\Github\volo\abp\framework\src\Volo.Abp.EventBus\Volo\Abp\EventBus\EventBusBase.cs:line 159
   at Volo.Abp.EventBus.EventBusBase.TriggerHandlersAsync(Type eventType, Object eventData, List`1 exceptions) in d:\Github\volo\abp\framework\src\Volo.Abp.EventBus\Volo\Abp\EventBus\EventBusBase.cs:line 113
   at Volo.Abp.EventBus.Local.LocalEventBus.PublishAsync(Type eventType, Object eventData) in d:\Github\volo\abp\framework\src\Volo.Abp.EventBus\Volo\Abp\EventBus\Local\LocalEventBus.cs:line 122
   at Volo.Abp.Uow.UnitOfWork.OnCompletedAsync() in d:\Github\volo\abp\framework\src\Volo.Abp.Uow\Volo\Abp\Uow\UnitOfWork.cs:line 244
   at Volo.Abp.Uow.UnitOfWork.CompleteAsync(CancellationToken cancellationToken) in d:\Github\volo\abp\framework\src\Volo.Abp.Uow\Volo\Abp\Uow\UnitOfWork.cs:line 135
   at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) in d:\Github\volo\abp\framework\src\Volo.Abp.Uow\Volo\Abp\Uow\UnitOfWorkInterceptor.cs:line 47
   at Volo.Abp.Castle.DynamicProxy.CastleAbpInterceptorAdapter`1.ExecuteWithReturnValueAsync[T](IInvocation invocation, IInvocationProceedInfo proceedInfo) in d:\Github\volo\abp\framework\src\Volo.Abp.Castle.Core\Volo\Abp\Castle\DynamicProxy\CastleAbpInterceptorAdapter.cs:line 82
   at Volo.Abp.Identity.IdentityUserAppService_Tests.CreateAsync() in D:\Github\volo\abp\modules\identity\test\Volo.Abp.Identity.Application.Tests\Volo\Abp\Identity\IdentityUserAppService_Tests.cs:line 72
--- End of stack trace from previous location where exception was thrown ---
@hikalkan
Copy link
Member

hikalkan commented Jul 3, 2019

I will check it. Thanks @maliming

@hikalkan hikalkan added this to the 0.19.0 milestone Jul 3, 2019
@hikalkan hikalkan self-assigned this Jul 3, 2019
@hikalkan
Copy link
Member

hikalkan commented Jul 3, 2019

I don't think this is related to IHybridServiceScopeFactory change, because it is just a plain wrapper for the IServiceScopeFactory for non-web apps.

I can be related to my refactor to reduce singletons.

This is the point before this commit: https://github.com/abpframework/abp/tree/63baeaa874b222bf61c19518bb681bff751f39e7

Can you create a temporary branch (like this:)

image

Then test if it still fails. If it does not fail, do it also for the commit https://github.com/abpframework/abp/tree/f719bda32f9b0469684d02e045d87eeabd2a833c

This will take your time, but no easy way to understand it, because using IServiceScopeFactory instead of IHybridServiceScopeFactory is a true decision :)

@hikalkan hikalkan assigned maliming and unassigned hikalkan Jul 3, 2019
@maliming
Copy link
Member Author

maliming commented Jul 4, 2019

f719bda#diff-3ca0b926da002b08040470e8c850a714L13

If the life cycle of LocalDistributedEventBus is SIingleton(ISingletonDependency) then there will be no problem.

@maliming
Copy link
Member Author

maliming commented Jul 4, 2019

@hikalkan
Copy link
Member

hikalkan commented Jul 4, 2019

If the life cycle of LocalDistributedEventBus is SIingleton(ISingletonDependency) then there will be no problem.

Fixed it. Thank you for finding this.

UnitOfWorkManager seems to have the same problem.

Did you find any problem (a failing test or another one) about this?

@hikalkan
Copy link
Member

hikalkan commented Jul 4, 2019

OK, I fixed both. Thanks for finding these.

@hikalkan hikalkan self-assigned this Jul 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants