Remove some of the field injections (Sonar recomendtion) (#2218)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-01-23 09:52:29 +02:00
committed by GitHub
parent 4909a65d8c
commit bb9c9bfad8
26 changed files with 294 additions and 297 deletions

View File

@@ -31,6 +31,7 @@ import org.springframework.security.web.access.intercept.AuthorizationFilter;
import org.springframework.web.filter.OncePerRequestFilter;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@SuppressWarnings("java:S6548") // java:S6548 - singleton holder ensures static access to spring resources in some places
public class MdcHandler {
public static final String MDC_KEY_TENANT = "tenant";
@@ -40,7 +41,6 @@ public class MdcHandler {
@Value("${hawkbit.logging.mdchandler.enabled:true}")
private boolean mdcEnabled;
@Autowired(required = false)
private SpringSecurityAuditorAware springSecurityAuditorAware = new SpringSecurityAuditorAware();
/**
@@ -50,6 +50,11 @@ public class MdcHandler {
return SINGLETON;
}
@Autowired(required = false) // spring setter injection
public void setSpringSecurityAuditorAware(final SpringSecurityAuditorAware springSecurityAuditorAware) {
this.springSecurityAuditorAware = springSecurityAuditorAware;
}
/**
* Executes callable and returns the result. If MDC is enabled, it sets the tenant and / or user from the authentication in the MDC context.
*