Issue #3804 - PathResource should not use SPARSE hint always
+ SPARSE hint only applies to real os file systems or default file systems, not for all file systems. Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
parent
e5bce5f7cd
commit
8601baa3cc
|
@ -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
|
||||
|
|
|
@ -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<String, Object> 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())));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue