Browse Source

Omit jar: prefix from jarFileUrl

pull/382/head
Dave Syer 12 years ago
parent
commit
825fc2f7df
  1. 4
      spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java
  2. 6
      spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java

4
spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java

@ -63,12 +63,12 @@ class JarURLConnection extends java.net.JarURLConnection {
* sensible for #getJarFileURL(). * sensible for #getJarFileURL().
*/ */
if (separator + SEPARATOR.length() != spec.length()) { if (separator + SEPARATOR.length() != spec.length()) {
this.jarFileUrl = new URL("jar:" + spec); this.jarFileUrl = new URL(spec);
this.jarEntryName = spec.substring(separator + 2); this.jarEntryName = spec.substring(separator + 2);
} }
else { else {
// The root of the archive (!/) // The root of the archive (!/)
this.jarFileUrl = new URL("jar:" + spec.substring(0, separator)); this.jarFileUrl = new URL(spec.substring(0, separator));
} }
} }

6
spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java

@ -150,7 +150,7 @@ public class JarFileTests {
assertThat(jarURLConnection.getContentLength(), greaterThan(1)); assertThat(jarURLConnection.getContentLength(), greaterThan(1));
assertThat(jarURLConnection.getContent(), sameInstance((Object) this.jarFile)); assertThat(jarURLConnection.getContent(), sameInstance((Object) this.jarFile));
assertThat(jarURLConnection.getContentType(), equalTo("x-java/jar")); assertThat(jarURLConnection.getContentType(), equalTo("x-java/jar"));
assertThat(jarURLConnection.getJarFileURL().toString(), equalTo("jar:file:" assertThat(jarURLConnection.getJarFileURL().toString(), equalTo("file:"
+ this.rootJarFile)); + this.rootJarFile));
} }
@ -216,8 +216,8 @@ public class JarFileTests {
+ "!/nested.jar!/")); + "!/nested.jar!/"));
JarURLConnection conn = (JarURLConnection) url.openConnection(); JarURLConnection conn = (JarURLConnection) url.openConnection();
assertThat(conn.getJarFile(), sameInstance(nestedJarFile)); assertThat(conn.getJarFile(), sameInstance(nestedJarFile));
assertThat(conn.getJarFileURL().toString(), equalTo("jar:file:" assertThat(conn.getJarFileURL().toString(),
+ this.rootJarFile.getPath() + "!/nested.jar")); equalTo("file:" + this.rootJarFile.getPath() + "!/nested.jar"));
} }
@Test @Test

Loading…
Cancel
Save