From 2d43781c5c23595fc41ef05eb73900c8e51ad1d9 Mon Sep 17 00:00:00 2001 From: "Daniel L. Buchko" Date: Fri, 23 Aug 2013 18:57:52 -0400 Subject: [PATCH 1/2] Fixed handling of spaces in file paths Update Launcher to correctly handle spaced in file paths. --- .../java/org/springframework/boot/loader/Launcher.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java index 5130b22fe19..0f8991a30ca 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java @@ -18,6 +18,7 @@ package org.springframework.boot.loader; import java.io.File; import java.lang.reflect.Constructor; +import java.net.URI; import java.net.URL; import java.security.CodeSource; import java.security.ProtectionDomain; @@ -67,13 +68,12 @@ public abstract class Launcher { protected void launch(String[] args, ProtectionDomain protectionDomain) throws Exception { CodeSource codeSource = protectionDomain.getCodeSource(); - URL codeSourceLocation = (codeSource == null ? null : codeSource.getLocation()); - String codeSourcePath = (codeSourceLocation == null ? null : codeSourceLocation - .getPath()); - if (codeSourcePath == null) { + URI location = (codeSource == null ? null : codeSource.getLocation().toURI()); + String path = (location == null ? null : location.getPath()); + if (path == null) { throw new IllegalStateException("Unable to determine code source archive"); } - File root = new File(codeSourcePath); + File root = new File(path); if (!root.exists()) { throw new IllegalStateException( "Unable to determine code source archive from " + root); From 08f1abce7b08a5132bed43fcae1cdd59154a6b61 Mon Sep 17 00:00:00 2001 From: "Daniel L. Buchko" Date: Fri, 23 Aug 2013 19:04:21 -0400 Subject: [PATCH 2/2] Prevent test failures under Windows Cleaned up file separators to prevent tests failing on Windows. --- .../org/springframework/boot/loader/ExplodedArchiveTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/ExplodedArchiveTests.java b/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/ExplodedArchiveTests.java index ac226d176bd..8210e10de7c 100644 --- a/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/ExplodedArchiveTests.java +++ b/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/ExplodedArchiveTests.java @@ -109,7 +109,7 @@ public class ExplodedArchiveTests { Entry entry = getEntriesMap(this.archive).get("nested.jar"); Archive nested = this.archive.getNestedArchive(entry); assertThat(nested.getUrl().toString(), - equalTo("jar:file:" + this.rootFolder.getPath() + "/nested.jar!/")); + equalTo("jar:file:" + this.rootFolder.getPath() + File.separator + "nested.jar!/")); } @Test @@ -119,7 +119,7 @@ public class ExplodedArchiveTests { Map nestedEntries = getEntriesMap(nested); assertThat(nestedEntries.size(), equalTo(1)); assertThat(nested.getUrl().toString(), - equalTo("file:" + this.rootFolder.getPath() + "/d/")); + equalTo("file:" + this.rootFolder.getPath() + File.separator + "d/")); } @Test