[#2527]: Simple UI/TargetView - handle no last poll (#2530)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-07-03 09:08:40 +03:00
committed by GitHub
parent 670ba00ff5
commit 047f94d4cb
3 changed files with 7 additions and 7 deletions

View File

@@ -54,4 +54,6 @@ public interface Constants {
String CANCEL_ESC = "Cancel (Esc)";
String NAME_ASC = "name:asc";
String NOT_AVAILABLE_NULL = "n/a (null)";
}

View File

@@ -225,11 +225,9 @@ public class RolloutView extends TableView<MgmtRolloutResponseBody, Long> {
targetFilter.setValue(rollout.getTargetFilterQuery());
final MgmtDistributionSet distributionSetMgmt = hawkbitClient.getDistributionSetRestApi()
.getDistributionSet(rollout.getDistributionSetId()).getBody();
if (distributionSetMgmt == null) { // should not be here
distributionSet.setValue("n/a (null)");
} else {
distributionSet.setValue(distributionSetMgmt.getName() + ":" + distributionSetMgmt.getVersion());
}
distributionSet.setValue(distributionSetMgmt == null
? NOT_AVAILABLE_NULL // should not be the case
: distributionSetMgmt.getName() + ":" + distributionSetMgmt.getVersion());
actonType.setValue(switch (rollout.getType()) {
case SOFT -> Constants.SOFT;
case FORCED -> Constants.FORCED;

View File

@@ -379,8 +379,8 @@ public class TargetView extends TableView<MgmtTarget, String> {
lastModifiedAt.setValue(new Date(target.getLastModifiedAt()).toString());
securityToken.setValue(target.getSecurityToken());
MgmtPollStatus pollStatus = target.getPollStatus();
lastPoll.setValue(new Date(pollStatus.getLastRequestAt()).toString());
final MgmtPollStatus pollStatus = target.getPollStatus();
lastPoll.setValue(pollStatus == null ? NOT_AVAILABLE_NULL : new Date(pollStatus.getLastRequestAt()).toString());
final ResponseEntity<MgmtTargetAttributes> response = hawkbitClient.getTargetRestApi().getAttributes(target.getControllerId());
if (response.getStatusCode().is2xxSuccessful()) {
targetAttributes.setValue(Objects.requireNonNullElse(response.getBody(), Collections.emptyMap()).entrySet().stream()