diff --git a/spring-bootstrap-launcher/src/main/java/org/springframework/bootstrap/launcher/jar/RandomAccessJarFile.java b/spring-bootstrap-launcher/src/main/java/org/springframework/bootstrap/launcher/jar/RandomAccessJarFile.java index 6dbd581021..526d3daf69 100644 --- a/spring-bootstrap-launcher/src/main/java/org/springframework/bootstrap/launcher/jar/RandomAccessJarFile.java +++ b/spring-bootstrap-launcher/src/main/java/org/springframework/bootstrap/launcher/jar/RandomAccessJarFile.java @@ -175,7 +175,11 @@ public class RandomAccessJarFile extends JarFile { @Override 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 diff --git a/spring-bootstrap-launcher/src/test/java/org/springframework/bootstrap/launcher/jar/RandomAccessJarFileTest.java b/spring-bootstrap-launcher/src/test/java/org/springframework/bootstrap/launcher/jar/RandomAccessJarFileTest.java index ca46a6241a..906290dc6e 100644 --- a/spring-bootstrap-launcher/src/test/java/org/springframework/bootstrap/launcher/jar/RandomAccessJarFileTest.java +++ b/spring-bootstrap-launcher/src/test/java/org/springframework/bootstrap/launcher/jar/RandomAccessJarFileTest.java @@ -52,7 +52,7 @@ import org.springframework.bootstrap.launcher.data.RandomAccessDataFile; /** * Tests for {@link RandomAccessJarFile}. - * + * * @author Phillip Webb */ public class RandomAccessJarFileTest { @@ -300,6 +300,13 @@ public class RandomAccessJarFileTest { 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 public void getFilteredJarFile() throws Exception { RandomAccessJarFile filteredJarFile = jarFile