diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/system/EmbeddedServerPortFileWriter.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/system/EmbeddedServerPortFileWriter.java index 2bf26637e6..539cf1bc13 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/system/EmbeddedServerPortFileWriter.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/system/EmbeddedServerPortFileWriter.java @@ -35,6 +35,8 @@ import org.springframework.util.StringUtils; * * @author David Liu * @author Phillip Webb + * @author Andy Wilkinson + * * @since 1.2.0 */ public class EmbeddedServerPortFileWriter implements @@ -122,7 +124,8 @@ public class EmbeddedServerPortFileWriter implements private boolean isUpperCase(String name) { for (int i = 0; i < name.length(); i++) { - if (!Character.isUpperCase(name.charAt(i))) { + if (Character.isLetter(name.charAt(i)) + && !Character.isUpperCase(name.charAt(i))) { return false; } } diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/system/EmbeddedServerPortFileWriterTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/system/EmbeddedServerPortFileWriterTests.java index 31f9455e9a..5393cf0c55 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/system/EmbeddedServerPortFileWriterTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/system/EmbeddedServerPortFileWriterTests.java @@ -18,6 +18,8 @@ package org.springframework.boot.actuate.system; import java.io.File; import java.io.FileReader; +import java.util.HashSet; +import java.util.Set; import org.junit.After; import org.junit.Before; @@ -31,6 +33,7 @@ import org.springframework.util.FileCopyUtils; import org.springframework.util.StringUtils; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasItem; import static org.junit.Assert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; @@ -40,6 +43,7 @@ import static org.mockito.Mockito.mock; * * @author David Liu * @author Phillip Webb + * @author Andy Wilkinson */ public class EmbeddedServerPortFileWriterTests { @@ -84,6 +88,7 @@ public class EmbeddedServerPortFileWriterTests { + StringUtils.getFilenameExtension(file.getName()); assertThat(FileCopyUtils.copyToString(new FileReader(new File(file .getParentFile(), managementFile))), equalTo("9090")); + assertThat(collectFileNames(file.getParentFile()), hasItem(managementFile)); } @Test @@ -99,7 +104,7 @@ public class EmbeddedServerPortFileWriterTests { + StringUtils.getFilenameExtension(file.getName()); assertThat(FileCopyUtils.copyToString(new FileReader(new File(file .getParentFile(), managementFile))), equalTo("9090")); - + assertThat(collectFileNames(file.getParentFile()), hasItem(managementFile)); } private EmbeddedServletContainerInitializedEvent mockEvent(String name, int port) { @@ -112,4 +117,14 @@ public class EmbeddedServerPortFileWriterTests { return event; } + private Set collectFileNames(File directory) { + Set names = new HashSet(); + if (directory.isDirectory()) { + for (File file : directory.listFiles()) { + names.add(file.getName()); + } + } + return names; + } + }