Fix sonar findings (#3135)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2026-06-12 13:05:12 +03:00
committed by GitHub
parent aa79097c1f
commit 0ed056c7f1
8 changed files with 15 additions and 18 deletions

View File

@@ -28,13 +28,12 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.listener.ConditionalRejectingErrorHandler;
import org.springframework.amqp.listener.FatalExceptionStrategy;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.listener.ConditionalRejectingErrorHandler;
import org.springframework.amqp.rabbit.listener.FatalExceptionStrategy;
import org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.amqp.support.converter.JacksonJsonMessageConverter;

View File

@@ -21,7 +21,7 @@ import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.exception.InvalidTargetAttributeException;
import org.eclipse.hawkbit.repository.exception.TenantNotExistException;
import org.springframework.amqp.rabbit.listener.FatalExceptionStrategy;
import org.springframework.amqp.listener.FatalExceptionStrategy;
import org.springframework.amqp.support.converter.MessageConversionException;
import org.springframework.messaging.MessageHandlingException;
import org.springframework.messaging.handler.invocation.MethodArgumentResolutionException;

View File

@@ -14,7 +14,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.amqp.rabbit.listener.FatalExceptionStrategy;
import org.springframework.amqp.listener.FatalExceptionStrategy;
import org.springframework.amqp.support.converter.MessageConversionException;
/**

View File

@@ -10,7 +10,7 @@
package org.eclipse.hawkbit.autoconfigure.dmf.amqp;
import org.eclipse.hawkbit.amqp.DmfApiConfiguration;
import org.springframework.amqp.rabbit.listener.ConditionalRejectingErrorHandler;
import org.springframework.amqp.listener.ConditionalRejectingErrorHandler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;

View File

@@ -495,16 +495,13 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati
@Test
void getDistributionSetTypesFilteredBySoftDeletedMode() throws Exception {
final DistributionSetType activeType = distributionSetTypeManagement.create(
DistributionSetTypeManagement.Create.builder()
.key("activeKey").name("activeType").build());
distributionSetTypeManagement.create(DistributionSetTypeManagement.Create.builder().key("activeKey").name("activeType").build());
// create type + DS using it, then delete type → soft-delete
final DistributionSetType deletedType = distributionSetTypeManagement.create(
DistributionSetTypeManagement.Create.builder()
.key("deletedKey").name("deletedType").build());
distributionSetManagement.create(DistributionSetManagement.Create.builder()
.type(deletedType).name("ds").version("1.0").build());
DistributionSetTypeManagement.Create.builder().key("deletedKey").name("deletedType").build());
distributionSetManagement.create(
DistributionSetManagement.Create.builder().type(deletedType).name("ds").version("1.0").build());
distributionSetTypeManagement.delete(deletedType.getId());
// default — built-in + activeType, no deletedType

View File

@@ -1230,8 +1230,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
@Test
void getSoftwareModulesFilteredBySoftDeletedMode() throws Exception {
final SoftwareModule activeSm = softwareModuleManagement.create(
SoftwareModuleManagement.Create.builder().type(osType).name("activeSm").version("1.0").build());
softwareModuleManagement.create(SoftwareModuleManagement.Create.builder().type(osType).name("activeSm").version("1.0").build());
SoftwareModule deletedSm = softwareModuleManagement.create(
SoftwareModuleManagement.Create.builder().type(osType).name("deletedSm").version("1.0").build());

View File

@@ -494,8 +494,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
// 3 built-in types exist (os, runtime, application)
final int builtInTypes = 3;
final SoftwareModuleType activeType = softwareModuleTypeManagement.create(
SoftwareModuleTypeManagement.Create.builder().key("activeKey").name("activeType").build());
softwareModuleTypeManagement.create(SoftwareModuleTypeManagement.Create.builder().key("activeKey").name("activeType").build());
// create type + SM using it, then delete type → soft-delete
final SoftwareModuleType deletedType = softwareModuleTypeManagement.create(

View File

@@ -12,6 +12,7 @@ package org.eclipse.hawkbit.ui.security;
import java.io.IOException;
import java.time.Instant;
import java.util.Collection;
import java.util.Objects;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
@@ -50,7 +51,9 @@ class UserDetailsSetter extends OncePerRequestFilter {
final Collection<? extends GrantedAuthority> grantedAuthorities = grantedAuthoritiesService.getGrantedAuthorities(authentication);
if (authentication instanceof OAuth2AuthenticationToken oAuth2AuthenticationToken) {
newAuthentication = new OAuth2AuthenticationToken(
oAuth2AuthenticationToken.getPrincipal(), grantedAuthorities,
// principal is not null, but the method is not @NonNull annotated
Objects.requireNonNull(oAuth2AuthenticationToken.getPrincipal()),
grantedAuthorities,
oAuth2AuthenticationToken.getAuthorizedClientRegistrationId());
if (authentication.getPrincipal() instanceof OidcUser user) {
// if there is no refresh token and the access token is expired then re-login is required