From 4313a43cc85701a8ef3aa4b09523ba7d54f2bbab Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 2 Jun 2015 09:36:04 -0700 Subject: [PATCH] Fix Windows slash issue with ChangedFile Update ChangedFile to clean paths when returning the relative name. See gh-3082 --- .../boot/developertools/filewatch/ChangedFile.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spring-boot-developer-tools/src/main/java/org/springframework/boot/developertools/filewatch/ChangedFile.java b/spring-boot-developer-tools/src/main/java/org/springframework/boot/developertools/filewatch/ChangedFile.java index 7c7e71e5309..b3ffef3c6c2 100644 --- a/spring-boot-developer-tools/src/main/java/org/springframework/boot/developertools/filewatch/ChangedFile.java +++ b/spring-boot-developer-tools/src/main/java/org/springframework/boot/developertools/filewatch/ChangedFile.java @@ -19,6 +19,7 @@ package org.springframework.boot.developertools.filewatch; import java.io.File; import org.springframework.util.Assert; +import org.springframework.util.StringUtils; /** * A single file that has changed. @@ -71,8 +72,10 @@ public final class ChangedFile { * @return the relative name */ public String getRelativeName() { - String folderName = this.sourceFolder.getAbsoluteFile().getPath(); - String fileName = this.file.getAbsoluteFile().getPath(); + File folder = this.sourceFolder.getAbsoluteFile(); + File file = this.file.getAbsoluteFile(); + String folderName = StringUtils.cleanPath(folder.getPath()); + String fileName = StringUtils.cleanPath(file.getPath()); Assert.state(fileName.startsWith(folderName), "The file " + fileName + " is not contained in the source folder " + folderName); return fileName.substring(folderName.length() + 1);