From f5b72b0714095cc6b4fe9d302e1ce858b570ba4e Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Mon, 18 Jan 2016 14:00:15 -0500 Subject: [PATCH] Load average on Windows is never available Since load average is never available on Windows, this commit modifies the handling of load average there to just always return null. --- .../src/main/java/org/elasticsearch/monitor/os/OsProbe.java | 3 +++ .../java/org/elasticsearch/monitor/os/OsProbeTests.java | 6 +----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/monitor/os/OsProbe.java b/core/src/main/java/org/elasticsearch/monitor/os/OsProbe.java index 3322c05fc97..5ee2232068f 100644 --- a/core/src/main/java/org/elasticsearch/monitor/os/OsProbe.java +++ b/core/src/main/java/org/elasticsearch/monitor/os/OsProbe.java @@ -119,6 +119,9 @@ public class OsProbe { } // fallback } + if (Constants.WINDOWS) { + return null; + } if (getSystemLoadAverage == null) { return null; } diff --git a/core/src/test/java/org/elasticsearch/monitor/os/OsProbeTests.java b/core/src/test/java/org/elasticsearch/monitor/os/OsProbeTests.java index 5aa1899c61d..2edaad5c4ba 100644 --- a/core/src/test/java/org/elasticsearch/monitor/os/OsProbeTests.java +++ b/core/src/test/java/org/elasticsearch/monitor/os/OsProbeTests.java @@ -55,11 +55,7 @@ public class OsProbeTests extends ESTestCase { } if (Constants.WINDOWS) { // load average is unavailable on Windows - if (loadAverage != null) { - assertThat(loadAverage[0], equalTo((double) -1)); - assertThat(loadAverage[1], equalTo((double) -1)); - assertThat(loadAverage[2], equalTo((double) -1)); - } + assertNull(loadAverage); } else if (Constants.LINUX) { // we should be able to get the load average assertNotNull(loadAverage);