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

Invalid interaction between DisposeAsync and Dispose in MultitenantContainer #19

Closed
me-viper opened this issue Mar 24, 2020 · 1 comment

Comments

@me-viper
Copy link
Contributor

me-viper commented Mar 24, 2020

  • Assembly version information for all project dependencies (packages.config, project.json)
    Current develop branch, commit ed664b9

  • The stack trace and message of any exception(s) encountered.

System.ObjectDisposedException : Cannot access a disposed object.
   at System.Threading.ReaderWriterLockSlim.TryEnterWriteLockCore(TimeoutTracker timeout)
   at System.Threading.ReaderWriterLockSlim.EnterWriteLock()
   at Autofac.Multitenant.MultitenantContainer.Dispose(Boolean disposing)
   at Autofac.Util.Disposable.DisposeAsync(Boolean disposing)
   at Autofac.Multitenant.MultitenantContainer.<>n__0(Boolean disposing)
   at Autofac.Multitenant.MultitenantContainer.DisposeAsync(Boolean disposing) 
  • If possible, a reproduction of the issue (ideally in a unit test form).
        [Fact]
        public async Task DisposeTest()
        {
            var strategy = new StubTenantIdentificationStrategy()
            {
                TenantId = "tenant1",
            };
            var mtc = new MultitenantContainer(strategy, new ContainerBuilder().Build());
            mtc.ConfigureTenant("tenant1", b => b.RegisterType<StubDependency1Impl1>().As<IStubDependency1>());

            await mtc.DisposeAsync();
        }

MultitenantContainer.AsyncDispose implementation does await base.DisposeAsync(disposing); call at the end. Disposable.DisposeAsync calls virtual Dispose() which causes call into MultitenantContainer.Dispose(). At the end code tries to access _readWriteLock that have been disposed already.

alistairjevans added a commit that referenced this issue Mar 24, 2020
Fixes issue #19: Invalid interaction between DisposeAsync and Dispose…
@tillig
Copy link
Member

tillig commented Mar 24, 2020

Fixed by #20

@tillig tillig closed this as completed Mar 24, 2020
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

2 participants