File tree Expand file tree Collapse file tree
spring-boot/src/main/java
org/baeldung/common/resources Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,12 +34,9 @@ private static void exitApplication() {
3434
3535 ConfigurableApplicationContext ctx = new SpringApplicationBuilder (Application .class ).web (false ).run ();
3636
37- int exitCode = SpringApplication .exit (ctx , new ExitCodeGenerator () {
38- @ Override
39- public int getExitCode () {
40- // return the error code
41- return 0 ;
42- }
37+ int exitCode = SpringApplication .exit (ctx , () -> {
38+ // return the error code
39+ return 0 ;
4340 });
4441
4542 System .out .println ("Exit Spring Boot" );
Original file line number Diff line number Diff line change 11package org .baeldung .common .resources ;
22
3+ import org .springframework .boot .ExitCodeGenerator ;
4+
35import java .util .Objects ;
46import java .util .concurrent .ExecutorService ;
57
6- import org .springframework .boot .ExitCodeGenerator ;
7-
88public class ExecutorServiceExitCodeGenerator implements ExitCodeGenerator {
99
1010 private ExecutorService executorService ;
@@ -14,16 +14,15 @@ public ExecutorServiceExitCodeGenerator(ExecutorService executorService) {
1414
1515 @ Override
1616 public int getExitCode () {
17- int returnCode = 0 ;
1817 try {
1918 if (!Objects .isNull (executorService )) {
2019 executorService .shutdownNow ();
21- returnCode = 1 ;
20+ return 1 ;
2221 }
22+
23+ return 0 ;
2324 } catch (SecurityException ex ) {
24- returnCode = 0 ;
25+ return 0 ;
2526 }
26- return returnCode ;
2727 }
28-
2928}
You can’t perform that action at this time.
0 commit comments