Skip to content

Commit 8457fc3

Browse files
committed
Adapt Windows path handling fix to deal with Jetty
Update `NestedLocation` to deal with the fact that Jetty attempts to fix URLs. See gh-40549
1 parent 7708ec7 commit 8457fc3

File tree

1 file changed

+13
-5
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/net/protocol/nested

1 file changed

+13
-5
lines changed

spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/net/protocol/nested/NestedLocation.java

+13-5
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,26 @@ private static NestedLocation create(String location) {
107107

108108
private static Path asPath(String locationPath) {
109109
return pathCache.computeIfAbsent(locationPath, (key) -> {
110-
if (isWindows() && locationPath.length() > 2 && locationPath.charAt(2) == ':') {
111-
// Use the same logic as Java's internal WindowsUriSupport class
112-
return Path.of(locationPath.substring(1));
113-
}
114-
return Path.of(locationPath);
110+
return Path.of((!isWindows()) ? locationPath : fixWindowsLocationPath(locationPath));
115111
});
116112
}
117113

118114
private static boolean isWindows() {
119115
return File.separatorChar == '\\';
120116
}
121117

118+
private static String fixWindowsLocationPath(String locationPath) {
119+
// Same logic as Java's internal WindowsUriSupport class
120+
if (locationPath.length() > 2 && locationPath.charAt(2) == ':') {
121+
return locationPath.substring(1);
122+
}
123+
// Deal with Jetty's org.eclipse.jetty.util.URIUtil#correctURI(URI)
124+
if (locationPath.startsWith("///") && locationPath.charAt(4) == ':') {
125+
return locationPath.substring(3);
126+
}
127+
return locationPath;
128+
}
129+
122130
static void clearCache() {
123131
locationCache.clear();
124132
pathCache.clear();

0 commit comments

Comments
 (0)