Fix SonarQube issues (2) (#2205)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -32,8 +32,8 @@ public final class AmqpErrorMessageComposer {
|
||||
*/
|
||||
public static String constructErrorMessage(final Throwable throwable) {
|
||||
final String mainErrorMsg = throwable.getCause().getMessage();
|
||||
if (throwable instanceof ListenerExecutionFailedException) {
|
||||
Collection<Message> failedMessages = ((ListenerExecutionFailedException) throwable).getFailedMessages();
|
||||
if (throwable instanceof ListenerExecutionFailedException listenerExecutionFailedException) {
|
||||
Collection<Message> failedMessages = listenerExecutionFailedException.getFailedMessages();
|
||||
// since the intended message content is always on top of the collection, we only extract the first one
|
||||
final Message failedMessage = failedMessages.iterator().next();
|
||||
final byte[] amqpFailedMsgBody = failedMessage.getBody();
|
||||
|
||||
@@ -370,7 +370,7 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
|
||||
// Handling remote request in parallel streams
|
||||
return StreamSupport.stream(partitions.spliterator(), true) //
|
||||
.flatMap(partition -> withSecurityContext(() -> loadingFunction.apply(partition), context).stream())
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
return loadingFunction.apply(controllerIds);
|
||||
}
|
||||
@@ -436,7 +436,7 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}).collect(Collectors.toList()));
|
||||
}).toList());
|
||||
}
|
||||
|
||||
private void sendUpdateMessageToTargets(
|
||||
@@ -570,7 +570,7 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
|
||||
}
|
||||
|
||||
private List<DmfMetadata> convertMetadata(final List<SoftwareModuleMetadata> metadata) {
|
||||
return metadata.stream().map(md -> new DmfMetadata(md.getKey(), md.getValue())).collect(Collectors.toList());
|
||||
return metadata.stream().map(md -> new DmfMetadata(md.getKey(), md.getValue())).toList();
|
||||
}
|
||||
|
||||
private List<DmfArtifact> convertArtifacts(final Target target, final List<Artifact> localArtifacts) {
|
||||
@@ -579,7 +579,7 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
|
||||
}
|
||||
|
||||
return localArtifacts.stream().map(localArtifact -> convertArtifact(target, localArtifact))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
private DmfArtifact convertArtifact(final Target target, final Artifact localArtifact) {
|
||||
@@ -619,7 +619,7 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
|
||||
final List<DmfTarget> dmfTargets = targets.stream()
|
||||
.filter(target -> IpUtil.isAmqpUri(target.getAddress()))
|
||||
.map(t -> convertToDmfTarget(t, actions.get(t.getControllerId()).getId()))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
|
||||
final DmfBatchDownloadAndUpdateRequest batchRequest = new DmfBatchDownloadAndUpdateRequest();
|
||||
batchRequest.setTimestamp(System.currentTimeMillis());
|
||||
|
||||
@@ -23,6 +23,8 @@ import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.hawkbit.dmf.amqp.api.EventTopic;
|
||||
import org.eclipse.hawkbit.dmf.amqp.api.MessageHeaderKey;
|
||||
@@ -215,7 +217,7 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
|
||||
|
||||
// Exception squid:MethodCyclomaticComplexity - false positive, is a simple mapping
|
||||
@SuppressWarnings("squid:MethodCyclomaticComplexity")
|
||||
private static Status mapStatus(final Message message, final DmfActionUpdateStatus actionUpdateStatus, final Action action) {
|
||||
private static @NotNull Status mapStatus(final Message message, final DmfActionUpdateStatus actionUpdateStatus, final Action action) {
|
||||
Status status = null;
|
||||
switch (actionUpdateStatus.getActionStatus()) {
|
||||
case DOWNLOAD: {
|
||||
@@ -226,8 +228,7 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
|
||||
status = Status.RETRIEVED;
|
||||
break;
|
||||
}
|
||||
case RUNNING:
|
||||
case CONFIRMED: {
|
||||
case RUNNING, CONFIRMED: {
|
||||
status = Status.RUNNING;
|
||||
break;
|
||||
}
|
||||
@@ -373,7 +374,7 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
|
||||
}
|
||||
|
||||
private Map<SoftwareModule, List<SoftwareModuleMetadata>> getSoftwareModulesWithMetadata(final DistributionSet distributionSet) {
|
||||
final List<Long> smIds = distributionSet.getModules().stream().map(SoftwareModule::getId).collect(Collectors.toList());
|
||||
final List<Long> smIds = distributionSet.getModules().stream().map(SoftwareModule::getId).toList();
|
||||
final Map<Long, List<SoftwareModuleMetadata>> metadata = controllerManagement.findTargetVisibleMetaDataBySoftwareModuleId(smIds);
|
||||
return distributionSet.getModules().stream().collect(Collectors.toMap(
|
||||
Function.identity(), sm -> metadata.getOrDefault(sm.getId(), Collections.emptyList())));
|
||||
|
||||
Reference in New Issue
Block a user