Avoiding Exception being thrown on @EventListener invocation (#5628)

* replaced EventListener annotation with @PreDestroy

* adding changelog

---------

Co-authored-by: peartree <etienne.poirier@smilecdr.com>
This commit is contained in:
Etienne Poirier 2024-01-25 11:18:44 -05:00 committed by GitHub
parent 4b1ac778cc
commit ba28ff977f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View File

@ -0,0 +1,5 @@
---
type: fix
issue: 5626
title: "Previously, an exception could be thrown by the container when executing a contextClosedEvent on the
Scheduler Service. This issue has been fixed."

View File

@ -28,13 +28,13 @@ import ca.uhn.fhir.jpa.model.sched.ScheduledJobDefinition;
import ca.uhn.fhir.util.StopWatch;
import com.google.common.annotations.VisibleForTesting;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import org.quartz.JobKey;
import org.quartz.SchedulerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.core.env.Environment;
@ -177,7 +177,7 @@ public abstract class BaseSchedulerServiceImpl implements ISchedulerService {
values.forEach(t -> t.scheduleJobs(this));
}
@EventListener(ContextClosedEvent.class)
@PreDestroy
public void stop() {
ourLog.info("Shutting down task scheduler...");