From 158416fdd092339928105eb456b81d41521c11a2 Mon Sep 17 00:00:00 2001 From: Huang YunKun Date: Sat, 17 Jun 2017 15:09:30 +0800 Subject: [PATCH] Use getUsableSpace() in DiskSpaceHealthIndicator See gh-9544 --- .../boot/actuate/health/DiskSpaceHealthIndicator.java | 2 +- .../boot/actuate/health/DiskSpaceHealthIndicatorTests.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/DiskSpaceHealthIndicator.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/DiskSpaceHealthIndicator.java index 914ccdc0a9..2c25bb7b9f 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/DiskSpaceHealthIndicator.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/DiskSpaceHealthIndicator.java @@ -46,7 +46,7 @@ public class DiskSpaceHealthIndicator extends AbstractHealthIndicator { @Override protected void doHealthCheck(Health.Builder builder) throws Exception { File path = this.properties.getPath(); - long diskFreeInBytes = path.getFreeSpace(); + long diskFreeInBytes = path.getUsableSpace(); if (diskFreeInBytes >= this.properties.getThreshold()) { builder.up(); } diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/DiskSpaceHealthIndicatorTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/DiskSpaceHealthIndicatorTests.java index 18bbc7f35e..01687b46f5 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/DiskSpaceHealthIndicatorTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/DiskSpaceHealthIndicatorTests.java @@ -56,7 +56,7 @@ public class DiskSpaceHealthIndicatorTests { @Test public void diskSpaceIsUp() throws Exception { - given(this.fileMock.getFreeSpace()).willReturn(THRESHOLD_BYTES + 10); + given(this.fileMock.getUsableSpace()).willReturn(THRESHOLD_BYTES + 10); given(this.fileMock.getTotalSpace()).willReturn(THRESHOLD_BYTES * 10); Health health = this.healthIndicator.health(); assertThat(health.getStatus()).isEqualTo(Status.UP); @@ -67,7 +67,7 @@ public class DiskSpaceHealthIndicatorTests { @Test public void diskSpaceIsDown() throws Exception { - given(this.fileMock.getFreeSpace()).willReturn(THRESHOLD_BYTES - 10); + given(this.fileMock.getUsableSpace()).willReturn(THRESHOLD_BYTES - 10); given(this.fileMock.getTotalSpace()).willReturn(THRESHOLD_BYTES * 10); Health health = this.healthIndicator.health(); assertThat(health.getStatus()).isEqualTo(Status.DOWN);