diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/PathResource.java b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/PathResource.java index 7530f13e5d9..3253fd2507e 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/PathResource.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/PathResource.java @@ -377,7 +377,8 @@ public class PathResource extends Resource @Override public InputStream getInputStream() throws IOException { - return Files.newInputStream(path, StandardOpenOption.READ, StandardOpenOption.SPARSE); + // TODO: investigate if SPARSE use for default FileSystem usages is worth it + return Files.newInputStream(path, StandardOpenOption.READ); } @Override @@ -389,7 +390,8 @@ public class PathResource extends Resource @Override public ReadableByteChannel getReadableByteChannel() throws IOException { - return Files.newByteChannel(path, StandardOpenOption.READ, StandardOpenOption.SPARSE); + // TODO: investigate if SPARSE use for default FileSystem usages is worth it + return Files.newByteChannel(path, StandardOpenOption.READ); } @Override diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/resource/PathResourceTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/resource/PathResourceTest.java index e12646f5bdc..a0fd66f0049 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/resource/PathResourceTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/resource/PathResourceTest.java @@ -57,15 +57,35 @@ public class PathResourceTest PathResource resource = new PathResource(manifestPath); - try (ReadableByteChannel channel = resource.getReadableByteChannel()) - { - assertThat("ReadableByteChannel", channel, is(not(nullValue()))); - } - try (InputStream inputStream = resource.getInputStream()) { assertThat("InputStream", inputStream, is(not(nullValue()))); } } } + + @Test + public void testNonDefaultFileSystem_GetReadableByteChannel() throws URISyntaxException, IOException + { + Path exampleJar = MavenTestingUtils.getTestResourcePathFile("example.jar"); + + URI uri = new URI("jar", exampleJar.toUri().toASCIIString(), null); + System.err.println("URI = " + uri); + + Map env = new HashMap<>(); + env.put("multi-release", "runtime"); + + try (FileSystem zipfs = FileSystems.newFileSystem(uri, env)) + { + Path manifestPath = zipfs.getPath("/META-INF/MANIFEST.MF"); + assertThat(manifestPath, is(not(nullValue()))); + + PathResource resource = new PathResource(manifestPath); + + try (ReadableByteChannel channel = resource.getReadableByteChannel()) + { + assertThat("ReadableByteChannel", channel, is(not(nullValue()))); + } + } + } }