Skip to content

Commit bbb5f40

Browse files
authored
Sonar Fixes (6) (#2214)
Signed-off-by: Avgustin Marinov <[email protected]>
1 parent e8406af commit bbb5f40

File tree

23 files changed

+95
-109
lines changed

23 files changed

+95
-109
lines changed

hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/repository/event/EventPublisherAutoConfiguration.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,10 @@
99
*/
1010
package org.eclipse.hawkbit.autoconfigure.repository.event;
1111

12-
import java.util.concurrent.Executor;
1312

14-
import io.protostuff.ProtostuffIOUtil;
15-
import io.protostuff.Schema;
16-
import org.eclipse.hawkbit.event.BusProtoStuffMessageConverter;
1713
import org.eclipse.hawkbit.event.EventPublisherConfiguration;
18-
import org.eclipse.hawkbit.repository.event.ApplicationEventFilter;
19-
import org.eclipse.hawkbit.repository.event.remote.RemoteTenantAwareEvent;
20-
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
21-
import org.eclipse.hawkbit.security.SystemSecurityContext;
22-
import org.springframework.beans.factory.annotation.Autowired;
23-
import org.springframework.beans.factory.annotation.Qualifier;
24-
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
25-
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
26-
import org.springframework.boot.context.properties.EnableConfigurationProperties;
27-
import org.springframework.cloud.bus.BusProperties;
28-
import org.springframework.cloud.bus.ConditionalOnBusEnabled;
29-
import org.springframework.cloud.bus.ServiceMatcher;
30-
import org.springframework.cloud.bus.jackson.RemoteApplicationEventScan;
31-
import org.springframework.context.ApplicationEvent;
32-
import org.springframework.context.annotation.Bean;
3314
import org.springframework.context.annotation.Configuration;
3415
import org.springframework.context.annotation.Import;
35-
import org.springframework.context.annotation.PropertySource;
36-
import org.springframework.context.event.ApplicationEventMulticaster;
37-
import org.springframework.context.event.SimpleApplicationEventMulticaster;
38-
import org.springframework.context.support.AbstractApplicationContext;
39-
import org.springframework.core.ResolvableType;
40-
import org.springframework.messaging.converter.MessageConverter;
4116

4217
/**
4318
* Autoconfiguration for the event bus.

hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/ExecutorAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public TaskScheduler taskScheduler() {
8686

8787
private static ThreadFactory threadFactory(final String format) {
8888
final AtomicLong count = new AtomicLong(0);
89-
return (runnable) -> {
89+
return runnable -> {
9090
final Thread thread = Executors.defaultThreadFactory().newThread(runnable);
9191
thread.setName(String.format(Locale.ROOT, format, count.getAndIncrement()));
9292
return thread;

hawkbit-core/src/test/java/org/eclipse/hawkbit/repository/FileNameFieldsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
import io.qameta.allure.Description;
2020
import org.junit.jupiter.api.Test;
2121

22-
public class FileNameFieldsTest {
22+
class FileNameFieldsTest {
2323

2424
@Test
2525
@Description("Verifies that fields classes are correctly implemented")
2626
@SuppressWarnings("unchecked")
27-
public void repositoryManagementMethodsArePreAuthorizedAnnotated() {
27+
void repositoryManagementMethodsArePreAuthorizedAnnotated() {
2828
final String packageName = getClass().getPackage().getName();
2929
try (final ScanResult scanResult = new ClassGraph().acceptPackages(packageName).scan()) {
3030
final List<? extends Class<? extends RsqlQueryField>> matchingClasses = scanResult.getAllClasses()

hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/FileSizeQuotaExceededException.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111

1212
import static org.eclipse.hawkbit.repository.SizeConversionHelper.byteValueToReadableString;
1313

14+
import lombok.EqualsAndHashCode;
1415
import org.eclipse.hawkbit.exception.AbstractServerRtException;
1516
import org.eclipse.hawkbit.exception.SpServerError;
1617

1718
/**
1819
* Thrown if file size quota is exceeded
1920
*/
21+
@EqualsAndHashCode(callSuper = true)
2022
public class FileSizeQuotaExceededException extends AbstractServerRtException {
2123

2224
private static final String MAX_ARTIFACT_SIZE_EXCEEDED = "Maximum artifact size (%s) exceeded.";

hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/IncompatibleTargetTypeException.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@
1313
import java.util.Collection;
1414
import java.util.Collections;
1515

16+
import lombok.EqualsAndHashCode;
1617
import org.eclipse.hawkbit.exception.AbstractServerRtException;
1718
import org.eclipse.hawkbit.exception.SpServerError;
1819
import org.eclipse.hawkbit.repository.model.DistributionSet;
1920
import org.eclipse.hawkbit.repository.model.Target;
2021
import org.eclipse.hawkbit.repository.model.TargetType;
2122

2223
/**
23-
* Thrown if user tries to assign a {@link DistributionSet} to a {@link Target}
24-
* that has an incompatible {@link TargetType}
24+
* Thrown if user tries to assign a {@link DistributionSet} to a {@link Target} that has an incompatible {@link TargetType}
2525
*/
26+
@EqualsAndHashCode(callSuper = true)
2627
public class IncompatibleTargetTypeException extends AbstractServerRtException {
2728

2829
@Serial

hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/InvalidConfirmationFeedbackException.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111

1212
import java.io.Serial;
1313

14+
import lombok.EqualsAndHashCode;
1415
import org.eclipse.hawkbit.exception.AbstractServerRtException;
1516
import org.eclipse.hawkbit.exception.SpServerError;
1617

1718
/**
18-
* This exception is indicating that the confirmation feedback cannot be
19-
* processed for a specific actions for different reasons which are listed as
20-
* enum {@link Reason}.
19+
* This exception is indicating that the confirmation feedback cannot be processed for a specific actions for different reasons which are
20+
* listed as enum {@link Reason}.
2121
*/
22+
@EqualsAndHashCode(callSuper = true)
2223
public class InvalidConfirmationFeedbackException extends AbstractServerRtException {
2324

2425
@Serial

hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/InvalidMaintenanceScheduleException.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@
1111

1212
import java.io.Serial;
1313

14+
import lombok.EqualsAndHashCode;
1415
import org.eclipse.hawkbit.exception.AbstractServerRtException;
1516
import org.eclipse.hawkbit.exception.SpServerError;
1617

1718
/**
18-
* This exception is thrown if trying to set a maintenance schedule that is
19-
* invalid. A maintenance schedule is considered to be valid only if schedule,
20-
* duration and timezone are all null, or are all valid; in which case there
21-
* should be at least one valid window after the current time.
19+
* This exception is thrown if trying to set a maintenance schedule that is invalid. A maintenance schedule is considered to be valid only if
20+
* schedule, duration and timezone are all null, or are all valid; in which case there should be at least one valid window after the current
21+
* time.
2222
*/
23+
@EqualsAndHashCode(callSuper = true)
2324
public class InvalidMaintenanceScheduleException extends AbstractServerRtException {
2425

2526
@Serial

hawkbit-repository/hawkbit-repository-jpa-eclipselink/src/main/java/org/eclipse/hawkbit/repository/jpa/HawkbitEclipseLinkJpaDialect.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ private static SQLException findSqlException(final RuntimeException jpaSystemExc
9191
Throwable exception = jpaSystemException;
9292
do {
9393
final Throwable cause = exception.getCause();
94-
if (cause instanceof SQLException) {
95-
return (SQLException) cause;
94+
if (cause instanceof SQLException sqlException) {
95+
return sqlException;
9696
}
9797
exception = cause;
9898
} while (exception != null);

hawkbit-repository/hawkbit-repository-jpa-eclipselink/src/main/java/org/eclipse/hawkbit/repository/jpa/model/EntityPropertyChangeListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void postUpdate(final DescriptorEvent event) {
3131
final Object object = event.getObject();
3232
if (((UpdateObjectQuery) event.getQuery()).getObjectChangeSet().getChangedAttributeNames().stream()
3333
.anyMatch(field -> !TARGET_UPDATE_EVENT_IGNORE_FIELDS.contains(field))) {
34-
AbstractJpaBaseEntity.doNotify(() -> ((EventAwareEntity) object).fireUpdateEvent());
34+
AbstractBaseEntity.doNotify(((EventAwareEntity) object)::fireUpdateEvent);
3535
}
3636
}
3737
}

hawkbit-repository/hawkbit-repository-jpa-hibernate/src/main/java/org/eclipse/hawkbit/repository/jpa/model/EntityPropertyChangeListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void onPostUpdate(final PostUpdateEvent event) {
5757
}
5858

5959
if (hasNonIgnoredChanges || !lastTargetQueryChanged) {
60-
AbstractJpaBaseEntity.doNotify(() -> ((EventAwareEntity) event.getEntity()).fireUpdateEvent());
60+
AbstractBaseEntity.doNotify(((EventAwareEntity) event.getEntity())::fireUpdateEvent);
6161
}
6262
}
6363

0 commit comments

Comments
 (0)