mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Merge branch '1.0.x'
Conflicts: spring-boot-dependencies/pom.xml spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java
This commit is contained in:
commit
2cadf4165f
@ -365,11 +365,6 @@ public class JarFile extends java.util.jar.JarFile implements Iterable<JarEntryD
|
||||
throw new IllegalArgumentException("ZipEntry must be contained in this file");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return (int) this.size;
|
||||
@ -380,11 +375,6 @@ public class JarFile extends java.util.jar.JarFile implements Iterable<JarEntryD
|
||||
this.rootFile.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a URL that can be used to access this JAR file. NOTE: the specified URL
|
||||
* cannot be serialized and or cloned.
|
||||
@ -393,7 +383,26 @@ public class JarFile extends java.util.jar.JarFile implements Iterable<JarEntryD
|
||||
*/
|
||||
public URL getUrl() throws MalformedURLException {
|
||||
Handler handler = new Handler(this);
|
||||
return new URL("jar", "", -1, "file:" + getName() + "!/", handler);
|
||||
String file = "file:" + getName(PathForm.SYSTEM_INDEPENDENT) + "!/";
|
||||
return new URL("jar", "", -1, file, handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getName(PathForm.SYSTEM_DEPENDENT);
|
||||
}
|
||||
|
||||
private String getName(PathForm pathForm) {
|
||||
if (pathForm == PathForm.SYSTEM_INDEPENDENT && File.separatorChar != '/') {
|
||||
return this.name.replace(File.separatorChar, '/');
|
||||
}
|
||||
return this.name;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -420,4 +429,20 @@ public class JarFile extends java.util.jar.JarFile implements Iterable<JarEntryD
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Different forms that paths can be returned.
|
||||
*/
|
||||
private static enum PathForm {
|
||||
|
||||
/**
|
||||
* Use system dependent paths (i.e. include backslashes on Windows)
|
||||
*/
|
||||
SYSTEM_DEPENDENT,
|
||||
|
||||
/**
|
||||
* Use system independent paths (i.e. replace backslashes on Windows)
|
||||
*/
|
||||
SYSTEM_INDEPENDENT
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,6 @@ public class JarFileTests {
|
||||
assertThat(urlClassLoader.getResource("special/\u00EB.dat"), notNullValue());
|
||||
assertThat(urlClassLoader.getResource("d/9.dat"), notNullValue());
|
||||
jarFile.close();
|
||||
urlClassLoader.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -135,7 +134,6 @@ public class JarFileTests {
|
||||
URLClassLoader urlClassLoader = new URLClassLoader(
|
||||
new URL[] { this.jarFile.getUrl() });
|
||||
assertThat(urlClassLoader.getResource("special/\u00EB.dat"), notNullValue());
|
||||
urlClassLoader.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user