Skip to content

Commit

Permalink
fix: double dispose
Browse files Browse the repository at this point in the history
  • Loading branch information
mvarendorff2 committed Oct 22, 2024
1 parent 2d85ca2 commit a7ec70b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Fluss/UnitOfWork/UnitOfWorkFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public async ValueTask Commit(Func<IWriteUnitOfWork, ValueTask> action)
await RetryPolicy
.ExecuteAsync(async () =>
{
using var unitOfWork = serviceProvider.GetRequiredService<UnitOfWork>();
using var scope = serviceProvider.CreateScope();
var unitOfWork = scope.ServiceProvider.GetRequiredService<UnitOfWork>();
await action(unitOfWork);
await unitOfWork.CommitInternal();
});
Expand All @@ -36,7 +37,8 @@ public async ValueTask<T> Commit<T>(Func<IWriteUnitOfWork, ValueTask<T>> action)
return await RetryPolicy
.ExecuteAsync(async () =>
{
using var unitOfWork = serviceProvider.GetRequiredService<UnitOfWork>();
using var scope = serviceProvider.CreateScope();
var unitOfWork = scope.ServiceProvider.GetRequiredService<UnitOfWork>();
var result = await action(unitOfWork);
await unitOfWork.CommitInternal();
return result;
Expand Down

0 comments on commit a7ec70b

Please sign in to comment.