fix: reset lifecycle thread name back to default when thread quits
@@ -700,9 +700,11 @@ public class Lifecycle {
return;
}
lifecycleThread = greengrassService.getContext().get(ExecutorService.class).submit(() -> {
- while (!isClosed.get()) {
+ String threadName = Thread.currentThread().getName();
try {
Thread.currentThread().setName(greengrassService.getName() + "-lifecycle");
+ while (!isClosed.get()) {
+ try {
startStateTransition();
return;
} catch (RejectedExecutionException e) {
@@ -719,6 +721,10 @@ public class Lifecycle {
logger.atInfo("service-state-transition-retry").log();
}
}
+ } finally {
+ Thread.currentThread().setName(threadName); // reset thread name so that if the thread is recycled it
+ // will not falsely claim to be a lifecycle thread.
+ }
});
}
