Skip to content

Commit f9af3e0

Browse files
fix: properly guard lifecycle result callbacks by generation
1 parent e1ac2f4 commit f9af3e0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/java/com/aws/greengrass/lifecyclemanager/GenericExternalService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,8 @@ protected void startup() throws InterruptedException {
383383
logger.atInfo().kv(EXIT_CODE, exit).log("Startup script exited");
384384
separateLogger.atInfo().kv(EXIT_CODE, exit).log("Startup script exited");
385385
State state = getState();
386-
if (startingStateGeneration == getStateGeneration() && State.STARTING.equals(state)
387-
|| State.RUNNING.equals(state)) {
386+
if (startingStateGeneration == getStateGeneration()
387+
&& (State.STARTING.equals(state) || State.RUNNING.equals(state))) {
388388
if (exit == 0 && State.STARTING.equals(state)) {
389389
reportState(State.RUNNING);
390390
} else if (exit != 0) {
@@ -543,7 +543,7 @@ private void handleRunScript() throws InterruptedException {
543543
if (timeout != null) {
544544
Exec processToClose = runResult.getExec();
545545
context.get(ScheduledExecutorService.class).schedule(() -> {
546-
if (processToClose.isRunning()) {
546+
if (processToClose.isRunning()) { // TODO: Should we have a generation check here as well?
547547
try {
548548
logger.atWarn("service-run-timed-out")
549549
.log("Service failed to run within timeout, calling close in process");

0 commit comments

Comments
 (0)