diff --git a/src/main/java/com/aws/greengrass/config/Topic.java b/src/main/java/com/aws/greengrass/config/Topic.java index 45b6066323..4dc72f3a71 100644 --- a/src/main/java/com/aws/greengrass/config/Topic.java +++ b/src/main/java/com/aws/greengrass/config/Topic.java @@ -128,6 +128,10 @@ private Topic overrideValue(Object nv) { return withNewerValue(this.modtime, nv); } + private Topic overrideValue(Object nv, long proposedModTime) { + return withNewerValue(proposedModTime, nv); + } + /** * Update the value in place without changing the timestamp. * @param nv new value @@ -141,6 +145,14 @@ public Topic overrideValue(Number nv) { return overrideValue((Object) nv); } + public Topic overrideValueWithCurrentTimestamp(String nv) { + return overrideValue(nv, System.currentTimeMillis()); + } + + public Topic overrideValueWithCurrentTimestamp(Number nv) { + return overrideValue(nv, System.currentTimeMillis()); + } + private Topic withValue(Object nv) { return withNewerValue(System.currentTimeMillis(), nv); } diff --git a/src/main/java/com/aws/greengrass/lifecyclemanager/Lifecycle.java b/src/main/java/com/aws/greengrass/lifecyclemanager/Lifecycle.java index d23d70190c..d2f7186ea3 100644 --- a/src/main/java/com/aws/greengrass/lifecyclemanager/Lifecycle.java +++ b/src/main/java/com/aws/greengrass/lifecyclemanager/Lifecycle.java @@ -441,9 +441,9 @@ void setState(State current, StateTransitionEvent stateTransitionEvent) { // Sync on State.class to make sure the order of setValue and globalNotifyStateChanged // are consistent across different services. try (LockScope ls = LockScope.lock(globalLock)) { - stateTopic.withValue(newState.ordinal()); - statusCodeTopic.withValue(stateTransitionEvent.getStatusCode().name()); - statusReasonTopic.withValue(stateTransitionEvent.getStatusReason()); + stateTopic.overrideValueWithCurrentTimestamp(newState.ordinal()); + statusCodeTopic.overrideValueWithCurrentTimestamp(stateTransitionEvent.getStatusCode().name()); + statusReasonTopic.overrideValueWithCurrentTimestamp(stateTransitionEvent.getStatusReason()); greengrassService.getContext().globalNotifyStateChanged(greengrassService, current, newState); } }