ARTEMIS-3799 Fix default ping command for Windows

The Windows ping command doesn't fail on destination host unreachable
This commit is contained in:
Domenico Francesco Bruscino 2022-04-26 15:49:14 +02:00 committed by clebertsuconic
parent 6a3df6412b
commit 17e318ec4d
2 changed files with 5 additions and 1 deletions

View File

@ -52,7 +52,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
public static final String IPV6_DEFAULT_COMMAND = "ping6 -c 1 %2$s"; public static final String IPV6_DEFAULT_COMMAND = "ping6 -c 1 %2$s";
public static final String IPV4_DEFAULT_COMMAND = Env.isMacOs() ? "ping -c 1 -t %d %s" : Env.isLinuxOs() ? "ping -c 1 -w %d %s" : "ping -n 1 -w %d %s"; public static final String IPV4_DEFAULT_COMMAND = Env.isMacOs() ? "ping -c 1 -t %d %s" : Env.isWindowsOs() ? "ping -n 1 -w %d %s | findstr /i TTL" : "ping -c 1 -w %d %s";
private String ipv4Command = IPV4_DEFAULT_COMMAND; private String ipv4Command = IPV4_DEFAULT_COMMAND;

View File

@ -62,6 +62,7 @@ public final class Env {
private static final String OS = System.getProperty("os.name").toLowerCase(); private static final String OS = System.getProperty("os.name").toLowerCase();
private static final boolean IS_LINUX = OS.startsWith("linux"); private static final boolean IS_LINUX = OS.startsWith("linux");
private static final boolean IS_MAC = OS.startsWith("mac"); private static final boolean IS_MAC = OS.startsWith("mac");
private static final boolean IS_WINDOWS = OS.startsWith("windows");
private Env() { private Env() {
@ -91,4 +92,7 @@ public final class Env {
return IS_MAC == true; return IS_MAC == true;
} }
public static boolean isWindowsOs() {
return IS_WINDOWS == true;
}
} }