Skip to content

Commit

Permalink
Fix try/finally block
Browse files Browse the repository at this point in the history
If getting existingFeature fails, we don't want the finally block to be executed.
  • Loading branch information
epsitec authored Sep 16, 2024
1 parent a0cf256 commit 41351c0
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ public async Task Invoke(HttpContext context)
httpContextAccessor.HttpContext ??= context;

//Replace the service providers feature with our tenant specific one
IServiceProvidersFeature existingFeature = null!;
var existingFeature = context.Features.Get<IServiceProvidersFeature>()!;
try
{
existingFeature = context.Features.Get<IServiceProvidersFeature>()!;
context.Features.Set<IServiceProvidersFeature>(new RequestServicesFeature(context, multiTenantServiceProviderScopeFactory));
await next.Invoke(context);
}
Expand Down

0 comments on commit 41351c0

Please sign in to comment.