Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasVitale committed Feb 4, 2024
1 parent c7d0043 commit 0d74a7e
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import com.thomasvitale.instrumentservice.multitenancy.context.TenantContextHolder;
import com.thomasvitale.instrumentservice.multitenancy.context.resolvers.HttpHeaderTenantResolver;
import com.thomasvitale.instrumentservice.multitenancy.exceptions.TenantNotFoundException;
import com.thomasvitale.instrumentservice.multitenancy.exceptions.TenantResolutionException;
import com.thomasvitale.instrumentservice.multitenancy.tenantdetails.TenantDetailsService;

Expand Down Expand Up @@ -39,15 +38,12 @@ public TenantContextFilter(HttpHeaderTenantResolver httpHeaderTenantResolver, Te
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
var tenantIdentifier = httpRequestTenantResolver.resolveTenantIdentifier(request);

if (StringUtils.hasText(tenantIdentifier)) {
if (!isTenantValid(tenantIdentifier)) {
throw new TenantNotFoundException("The specified tenant doesn't exist or it's not enabled");
}
if (StringUtils.hasText(tenantIdentifier) && isTenantValid(tenantIdentifier)) {
TenantContextHolder.setTenantIdentifier(tenantIdentifier);
configureLogs(tenantIdentifier);
configureTraces(tenantIdentifier, request);
} else {
throw new TenantResolutionException("A tenant must be specified for requests to %s".formatted(request.getRequestURI()));
throw new TenantResolutionException("A valid tenant must be specified for requests to %s".formatted(request.getRequestURI()));
}

try {
Expand Down

0 comments on commit 0d74a7e

Please sign in to comment.