Fix some sonar finings (2) (#1653)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -111,7 +111,7 @@ public class MultiDeviceApp {
|
||||
public void stopOne(@ShellOption("--id") final String controllerId) {
|
||||
final DdiController device = devices.get(controllerId);
|
||||
if (device == null) {
|
||||
System.out.println("ERROR: controller with id " + controllerId + " not found!");
|
||||
throw new IllegalArgumentException("Controller with id " + controllerId + " not found!");
|
||||
} else {
|
||||
device.stop();
|
||||
}
|
||||
@@ -123,7 +123,7 @@ public class MultiDeviceApp {
|
||||
@ShellOption(value = "--offset", defaultValue = "0") final int offset,
|
||||
@ShellOption(value = "--count") final int count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
startOne(String.format(prefix + "%03d", offset + i));
|
||||
startOne(toId(prefix, offset + i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,8 +133,12 @@ public class MultiDeviceApp {
|
||||
@ShellOption(value = "--offset", defaultValue = "0") final int offset,
|
||||
@ShellOption(value = "--count") final int count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
stopOne(String.format(prefix + "%03d", offset + i));
|
||||
stopOne(toId(prefix, offset + i));
|
||||
}
|
||||
}
|
||||
|
||||
private static String toId(final String prefix, final int index) {
|
||||
return String.format("%s%03d", prefix, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.KeyStoreException;
|
||||
@@ -171,10 +172,12 @@ public interface UpdateHandler {
|
||||
*/
|
||||
protected void cleanup() {
|
||||
downloads.values().forEach(path -> {
|
||||
if (!path.toFile().delete()) {
|
||||
try {
|
||||
Files.delete(path);
|
||||
} catch (final IOException e) {
|
||||
log.warn(LOG_PREFIX + "Failed to cleanup {}",
|
||||
ddiController.getTenantId(), ddiController.getControllerId(),
|
||||
path.toFile().getAbsolutePath());
|
||||
path.toFile().getAbsolutePath(), e);
|
||||
}
|
||||
});
|
||||
log.debug(LOG_PREFIX + "Cleaned up", ddiController.getTenantId(), ddiController.getControllerId());
|
||||
|
||||
Reference in New Issue
Block a user