Issue #3840 Slow skip for PathResource (#3845)

Reverted to use FileInputStream

Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
Greg Wilkins 2019-07-03 11:48:49 +02:00 committed by GitHub
parent 5c91e44eaf
commit f84337d5b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 8 deletions

View File

@ -19,6 +19,7 @@
package org.eclipse.jetty.util.resource;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
@ -378,14 +379,9 @@ public class PathResource extends Resource
@Override
public InputStream getInputStream() throws IOException
{
/* Mimic behavior from old FileResource class and its
* usage of java.io.FileInputStream(File) which will trigger
* an IOException on construction if the path is a directory
*/
if (Files.isDirectory(path))
throw new IOException(path + " is a directory");
return Files.newInputStream(path, StandardOpenOption.READ);
// Use a FileInputStream rather than Files.newInputStream(path)
// since it produces a stream with a fast skip implementation
return new FileInputStream(getFile());
}
@Override