Closed Cynicszm closed 5 months ago
InMemoryStorage
class now implements IDisposable
. So something is calling the Dispose
method. Try creating instances of this class explicitly for each test, instead of relying on a static instance in JobStorage.Current
. In this case, unit tests will be properly isolated, and you will not have any shared state between test runs.
Thanks for the quick response.
I've moved some of the JobStorage usages around and it appears to be behaving for now.
Appreciate the help.
Great, thanks for the update!
Hi,
We are now getting object disposed exceptions in NUnit (4.1.0) after upgrading Hangfire InMemory from 0.8.1 to 0.9.0
Individual tests pass but fail on committing the write transaction when run concurrently.
Code snippet: `public string CreateToken( TimeSpan expireIn ) { var tokenId = Guid.NewGuid().ToString( "N" ); var resourceKey = "execution-tokens:" + tokenId;
}`
Stack: System.ObjectDisposedException : Cannot access a disposed object. Object name: 'Hangfire.InMemory.InMemoryDispatcher'. at Hangfire.InMemory.InMemoryDispatcher.ThrowObjectDisposedException() in //src/Hangfire.InMemory/InMemoryDispatcher.cs:line 136 at Hangfire.InMemory.InMemoryDispatcher.QueryAndWait(Func`3 query) in //src/Hangfire.InMemory/InMemoryDispatcher.cs:line 58 at Hangfire.InMemory.InMemoryDispatcherBase.QueryAndWait[T](Func
3 query) in /_/src/Hangfire.InMemory/InMemoryDispatcherBase.cs:line 126 at Hangfire.InMemory.InMemoryDispatcherBase.QueryAndWait(Action
2 query) in //src/Hangfire.InMemory/InMemoryDispatcherBase.cs:line 120 at Hangfire.InMemory.InMemoryTransaction.Commit() in //src/Hangfire.InMemory/InMemoryTransaction.cs:line 51