* NatsClient refactor

* Use lambda
This commit is contained in:
Grzegorz Piwowarek 2018-04-11 12:20:03 +02:00 committed by GitHub
parent df42f243f2
commit 0e95588c54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 15 deletions

View File

@ -34,12 +34,9 @@ public class Application {
ConfigurableApplicationContext ctx = new SpringApplicationBuilder(Application.class).web(false).run();
int exitCode = SpringApplication.exit(ctx, new ExitCodeGenerator() {
@Override
public int getExitCode() {
// return the error code
return 0;
}
int exitCode = SpringApplication.exit(ctx, () -> {
// return the error code
return 0;
});
System.out.println("Exit Spring Boot");

View File

@ -1,10 +1,10 @@
package org.baeldung.common.resources;
import org.springframework.boot.ExitCodeGenerator;
import java.util.Objects;
import java.util.concurrent.ExecutorService;
import org.springframework.boot.ExitCodeGenerator;
public class ExecutorServiceExitCodeGenerator implements ExitCodeGenerator {
private ExecutorService executorService;
@ -14,16 +14,15 @@ public class ExecutorServiceExitCodeGenerator implements ExitCodeGenerator {
@Override
public int getExitCode() {
int returnCode = 0;
try {
if (!Objects.isNull(executorService)) {
executorService.shutdownNow();
returnCode = 1;
return 1;
}
} catch (SecurityException ex) {
returnCode = 0;
}
return returnCode;
}
return 0;
} catch (SecurityException ex) {
return 0;
}
}
}