Skip to content

Commit

Permalink
javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
mvysny committed Oct 3, 2024
1 parent 20a603b commit 2e6ccee
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/com/vaadin/starter/skeleton/Bootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import java.util.Objects;
import java.util.concurrent.*;
import java.util.function.Consumer;

/**
* The {@link #contextInitialized(ServletContextEvent)} is called once,
Expand All @@ -21,6 +20,9 @@
public class Bootstrap implements ServletContextListener {
private static final Logger log = LoggerFactory.getLogger(Bootstrap.class);

/**
* Runs jobs in background thread.
*/
private static volatile ExecutorService executorService;

@Override
Expand All @@ -34,7 +36,10 @@ public void contextInitialized(ServletContextEvent sce) {
public void contextDestroyed(ServletContextEvent sce) {
try {
executorService.shutdown();
executorService.awaitTermination(10L, TimeUnit.SECONDS);
if (!executorService.awaitTermination(10L, TimeUnit.SECONDS)) {
// stop being nice: shutdown jobs immediately, interrupting all ongoing jobs.
executorService.shutdownNow();
}
} catch (InterruptedException e) {
log.error("Error while shutting down background jobs", e);
}
Expand Down

0 comments on commit 2e6ccee

Please sign in to comment.