mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Cache outcome of checking to see if host supports ANSI output
Closes gh-4510
This commit is contained in:
parent
8dc3b71ced
commit
b36fe2cbd8
@ -30,6 +30,8 @@ public abstract class AnsiOutput {
|
|||||||
|
|
||||||
private static Enabled enabled = Enabled.DETECT;
|
private static Enabled enabled = Enabled.DETECT;
|
||||||
|
|
||||||
|
private static Boolean ansiCapable;
|
||||||
|
|
||||||
private static final String OPERATING_SYSTEM_NAME = System.getProperty("os.name")
|
private static final String OPERATING_SYSTEM_NAME = System.getProperty("os.name")
|
||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
|
|
||||||
@ -108,12 +110,19 @@ public abstract class AnsiOutput {
|
|||||||
|
|
||||||
private static boolean isEnabled() {
|
private static boolean isEnabled() {
|
||||||
if (enabled == Enabled.DETECT) {
|
if (enabled == Enabled.DETECT) {
|
||||||
return detectIfEnabled();
|
return detectIfAnsiCapable();
|
||||||
}
|
}
|
||||||
return enabled == Enabled.ALWAYS;
|
return enabled == Enabled.ALWAYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean detectIfEnabled() {
|
private static boolean detectIfAnsiCapable() {
|
||||||
|
if (ansiCapable == null) {
|
||||||
|
ansiCapable = doDetectIfAnsiCapable();
|
||||||
|
}
|
||||||
|
return ansiCapable;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean doDetectIfAnsiCapable() {
|
||||||
try {
|
try {
|
||||||
if (System.console() == null) {
|
if (System.console() == null) {
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user