mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8205612: (fc) Files.readAllBytes fails with ClosedByInterruptException when interrupt status set
Reviewed-by: bpb
This commit is contained in:
parent
4e844fe623
commit
807c4ae4a3
4 changed files with 233 additions and 46 deletions
|
@ -77,6 +77,7 @@ import java.util.function.BiPredicate;
|
|||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import sun.nio.ch.FileChannelImpl;
|
||||
import sun.nio.fs.AbstractFileSystemProvider;
|
||||
|
||||
/**
|
||||
|
@ -3203,10 +3204,11 @@ public final class Files {
|
|||
public static byte[] readAllBytes(Path path) throws IOException {
|
||||
try (SeekableByteChannel sbc = Files.newByteChannel(path);
|
||||
InputStream in = Channels.newInputStream(sbc)) {
|
||||
if (sbc instanceof FileChannelImpl)
|
||||
((FileChannelImpl) sbc).setUninterruptible();
|
||||
long size = sbc.size();
|
||||
if (size > (long)MAX_BUFFER_SIZE)
|
||||
if (size > (long) MAX_BUFFER_SIZE)
|
||||
throw new OutOfMemoryError("Required array size too large");
|
||||
|
||||
return read(in, (int)size);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue