mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Support reading entries without trailing '/'
Update RandomAccessJarFile entries when the name is specified without a trailing '/'
This commit is contained in:
parent
f00eed4b07
commit
1dbafae748
@ -175,7 +175,11 @@ public class RandomAccessJarFile extends JarFile {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ZipEntry getEntry(String name) {
|
public ZipEntry getEntry(String name) {
|
||||||
return this.entries.get(name);
|
JarEntry entry = this.entries.get(name);
|
||||||
|
if (entry == null && name != null && !name.endsWith("/")) {
|
||||||
|
entry = this.entries.get(name + "/");
|
||||||
|
}
|
||||||
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -300,6 +300,13 @@ public class RandomAccessJarFileTest {
|
|||||||
assertThat(inputStream.read(), equalTo(-1));
|
assertThat(inputStream.read(), equalTo(-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getDirectoryInputStreamWithoutSlash() throws Exception {
|
||||||
|
InputStream inputStream = jarFile.getInputStream(jarFile.getEntry("d"));
|
||||||
|
assertThat(inputStream, notNullValue());
|
||||||
|
assertThat(inputStream.read(), equalTo(-1));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getFilteredJarFile() throws Exception {
|
public void getFilteredJarFile() throws Exception {
|
||||||
RandomAccessJarFile filteredJarFile = jarFile
|
RandomAccessJarFile filteredJarFile = jarFile
|
||||||
|
Loading…
Reference in New Issue
Block a user