Refactoring/Improving source: loggers (lombok) (#1615)

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2024-02-04 13:26:08 +02:00
committed by GitHub
parent d220553157
commit 115397ef72
3 changed files with 12 additions and 23 deletions

View File

@@ -21,10 +21,8 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy; import java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Function;
import org.slf4j.Logger; import lombok.extern.slf4j.Slf4j;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
@@ -38,18 +36,14 @@ import org.springframework.security.concurrent.DelegatingSecurityContextExecutor
import org.springframework.security.concurrent.DelegatingSecurityContextExecutorService; import org.springframework.security.concurrent.DelegatingSecurityContextExecutorService;
import org.springframework.security.concurrent.DelegatingSecurityContextScheduledExecutorService; import org.springframework.security.concurrent.DelegatingSecurityContextScheduledExecutorService;
import static java.util.Objects.requireNonNull;
/** /**
* Central event processors inside update server. * Central event processors inside update server.
*
*/ */
@Slf4j
@Configuration @Configuration
@EnableConfigurationProperties(AsyncConfigurerThreadpoolProperties.class) @EnableConfigurationProperties(AsyncConfigurerThreadpoolProperties.class)
public class ExecutorAutoConfiguration { public class ExecutorAutoConfiguration {
private static final Logger LOGGER = LoggerFactory.getLogger(ExecutorAutoConfiguration.class);
@Autowired @Autowired
private AsyncConfigurerThreadpoolProperties asyncConfigurerProperties; private AsyncConfigurerThreadpoolProperties asyncConfigurerProperties;
@@ -89,7 +83,7 @@ public class ExecutorAutoConfiguration {
private static class PoolSizeExceededPolicy extends CallerRunsPolicy { private static class PoolSizeExceededPolicy extends CallerRunsPolicy {
@Override @Override
public void rejectedExecution(final Runnable r, final ThreadPoolExecutor executor) { public void rejectedExecution(final Runnable r, final ThreadPoolExecutor executor) {
LOGGER.warn( log.warn(
"Caller has to run on its own instead of centralExecutorService, reached limit of queue size {}", "Caller has to run on its own instead of centralExecutorService, reached limit of queue size {}",
executor.getQueue().size()); executor.getQueue().size());
super.rejectedExecution(r, executor); super.rejectedExecution(r, executor);

View File

@@ -22,6 +22,7 @@ import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse; import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.hawkbit.cache.DownloadIdCache; import org.eclipse.hawkbit.cache.DownloadIdCache;
import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants; import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants;
import org.eclipse.hawkbit.ddi.rest.resource.DdiApiConfiguration; import org.eclipse.hawkbit.ddi.rest.resource.DdiApiConfiguration;
@@ -45,8 +46,6 @@ import org.eclipse.hawkbit.security.HttpDownloadAuthenticationFilter;
import org.eclipse.hawkbit.security.PreAuthTokenSourceTrustAuthenticationProvider; import org.eclipse.hawkbit.security.PreAuthTokenSourceTrustAuthenticationProvider;
import org.eclipse.hawkbit.security.SystemSecurityContext; import org.eclipse.hawkbit.security.SystemSecurityContext;
import org.eclipse.hawkbit.tenancy.TenantAware; import org.eclipse.hawkbit.tenancy.TenantAware;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@@ -86,7 +85,6 @@ import org.springframework.security.web.firewall.FirewalledRequest;
import org.springframework.security.web.firewall.HttpFirewall; import org.springframework.security.web.firewall.HttpFirewall;
import org.springframework.security.web.firewall.StrictHttpFirewall; import org.springframework.security.web.firewall.StrictHttpFirewall;
import org.springframework.security.web.session.SessionManagementFilter; import org.springframework.security.web.session.SessionManagementFilter;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.CorsConfiguration;
@@ -96,6 +94,7 @@ import org.springframework.web.cors.CorsConfigurationSource;
* All configurations related to HawkBit's authentication and authorization * All configurations related to HawkBit's authentication and authorization
* layer. * layer.
*/ */
@Slf4j
@Configuration @Configuration
@EnableWebSecurity @EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true, mode = AdviceMode.ASPECTJ, proxyTargetClass = true, securedEnabled = true) @EnableGlobalMethodSecurity(prePostEnabled = true, mode = AdviceMode.ASPECTJ, proxyTargetClass = true, securedEnabled = true)
@@ -103,8 +102,6 @@ import org.springframework.web.cors.CorsConfigurationSource;
@PropertySource("classpath:/hawkbit-security-defaults.properties") @PropertySource("classpath:/hawkbit-security-defaults.properties")
public class SecurityManagedConfiguration { public class SecurityManagedConfiguration {
private static final Logger LOG = LoggerFactory.getLogger(SecurityManagedConfiguration.class);
private static final int DOS_FILTER_ORDER = -200; private static final int DOS_FILTER_ORDER = -200;
/** /**
@@ -206,7 +203,7 @@ public class SecurityManagedConfiguration {
final ControllerTenantAwareAuthenticationDetailsSource authenticationDetailsSource = new ControllerTenantAwareAuthenticationDetailsSource(); final ControllerTenantAwareAuthenticationDetailsSource authenticationDetailsSource = new ControllerTenantAwareAuthenticationDetailsSource();
if (ddiSecurityConfiguration.getAuthentication().getAnonymous().isEnabled()) { if (ddiSecurityConfiguration.getAuthentication().getAnonymous().isEnabled()) {
LOG.info( log.info(
""" """
****************** ******************
** Anonymous controller security enabled, should only be used for developing purposes ** ** Anonymous controller security enabled, should only be used for developing purposes **
@@ -325,7 +322,7 @@ public class SecurityManagedConfiguration {
final ControllerTenantAwareAuthenticationDetailsSource authenticationDetailsSource = new ControllerTenantAwareAuthenticationDetailsSource(); final ControllerTenantAwareAuthenticationDetailsSource authenticationDetailsSource = new ControllerTenantAwareAuthenticationDetailsSource();
if (ddiSecurityConfiguration.getAuthentication().getAnonymous().isEnabled()) { if (ddiSecurityConfiguration.getAuthentication().getAnonymous().isEnabled()) {
LOG.info( log.info(
""" """
****************** ******************
** Anonymous controller security enabled, should only be used for developing purposes ** ** Anonymous controller security enabled, should only be used for developing purposes **
@@ -602,7 +599,7 @@ public class SecurityManagedConfiguration {
if (!CollectionUtils.isEmpty(allowedHostNames)) { if (!CollectionUtils.isEmpty(allowedHostNames)) {
firewall.setAllowedHostnames(hostName -> { firewall.setAllowedHostnames(hostName -> {
LOG.debug("Firewall check host: {}, allowed: {}", hostName, allowedHostNames.contains(hostName)); log.debug("Firewall check host: {}, allowed: {}", hostName, allowedHostNames.contains(hostName));
return allowedHostNames.contains(hostName); return allowedHostNames.contains(hostName);
}); });
} }

View File

@@ -14,6 +14,8 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.eclipse.hawkbit.mgmt.json.model.action.MgmtAction; import org.eclipse.hawkbit.mgmt.json.model.action.MgmtAction;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRepresentationMode; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRepresentationMode;
import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action;
@@ -23,12 +25,9 @@ import org.eclipse.hawkbit.rest.data.ResponseList;
* A mapper which maps repository model to RESTful model representation and * A mapper which maps repository model to RESTful model representation and
* back. * back.
*/ */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class MgmtActionMapper { public final class MgmtActionMapper {
private MgmtActionMapper() {
// Utility class
}
/** /**
* Create a response for actions. * Create a response for actions.
* *
@@ -54,5 +53,4 @@ public final class MgmtActionMapper {
} }
return MgmtTargetMapper.toResponseWithLinks(controllerId, action); return MgmtTargetMapper.toResponseWithLinks(controllerId, action);
} }
}
}