Skip to content

Commit e2880ee

Browse files
committed
Polish "Improve ExitCodeGenerator doc"
Closes gh-9740
1 parent cf2ebbc commit e2880ee

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -337,29 +337,30 @@ be used.
337337

338338
In addition, beans may implement the `org.springframework.boot.ExitCodeGenerator`
339339
interface if they wish to return a specific exit code when `SpringApplication.exit()`
340-
is called. This exit code can then be passed to `System.exit()` to pass it to the outside.
340+
is called. This exit code can then be passed to `System.exit()` to return it as a status
341+
code.
341342

342343
[source,java,indent=0]
343344
----
344345
@SpringBootApplication
345-
public class ExitCodeApplication {
346+
public class ExitCodeApplication {
346347
347-
public static void main(String[] args) {
348-
System.exit(SpringApplication.exit(SpringApplication.run(ExitCodeApplication.class, args)));
349-
}
348+
public static void main(String[] args) {
349+
System.exit(SpringApplication.exit(
350+
SpringApplication.run(ExitCodeApplication.class, args)));
351+
}
350352
351-
@Bean
352-
public ExitCodeGenerator exitCodeGenerator(){
353-
return () -> 42;
354-
}
353+
@Bean
354+
public ExitCodeGenerator exitCodeGenerator(){
355+
return () -> 42;
356+
}
355357
356-
}
358+
}
357359
----
358360

359-
Also, the `ExitCodeGenerator` interface may be implemented by exceptions. When such an exception is
360-
encountered, Spring Boot will return the exit code provided by the implemented `getExitCode()` method
361-
to the outside caller.
362-
361+
Also, the `ExitCodeGenerator` interface may be implemented by exceptions. When such an
362+
exception is encountered, Spring Boot will return the exit code provided by the
363+
implemented `getExitCode()` method.
363364

364365

365366
[[boot-features-application-admin]]

spring-boot/src/main/java/org/springframework/boot/ExitCodeGenerator.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 the original author or authors.
2+
* Copyright 2012-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,8 +18,7 @@
1818

1919
/**
2020
* Interface used to generate an 'exit code' from a running command line
21-
* {@link SpringApplication}. Since 1.3.2 this interface can be used on exceptions as well
22-
* as directly on beans.
21+
* {@link SpringApplication}. Can be used on exceptions as well as directly on beans.
2322
*
2423
* @author Dave Syer
2524
* @see SpringApplication#exit(org.springframework.context.ApplicationContext,

0 commit comments

Comments
 (0)