| 
14 | 14 | import io.vertx.codegen.annotations.Nullable;  | 
15 | 15 | import io.vertx.core.Future;  | 
16 | 16 | import io.vertx.core.buffer.Buffer;  | 
17 |  | -import io.vertx.core.file.AsyncFile;  | 
18 |  | -import io.vertx.core.file.CopyOptions;  | 
19 |  | -import io.vertx.core.file.FileProps;  | 
 | 17 | +import io.vertx.core.file.*;  | 
20 | 18 | import io.vertx.core.file.FileSystem;  | 
21 | 19 | import io.vertx.core.file.FileSystemException;  | 
22 |  | -import io.vertx.core.file.FileSystemProps;  | 
23 |  | -import io.vertx.core.file.OpenOptions;  | 
24 | 20 | import io.vertx.core.internal.ContextInternal;  | 
25 | 21 | import io.vertx.core.internal.VertxInternal;  | 
 | 22 | +import io.vertx.core.internal.buffer.BufferInternal;  | 
26 | 23 | 
 
  | 
27 | 24 | import java.io.File;  | 
28 | 25 | import java.io.FilenameFilter;  | 
29 | 26 | import java.io.IOException;  | 
30 | 27 | import java.io.RandomAccessFile;  | 
31 |  | -import java.nio.file.CopyOption;  | 
32 |  | -import java.nio.file.FileAlreadyExistsException;  | 
33 |  | -import java.nio.file.FileStore;  | 
34 |  | -import java.nio.file.FileVisitOption;  | 
35 |  | -import java.nio.file.FileVisitResult;  | 
36 |  | -import java.nio.file.Files;  | 
37 |  | -import java.nio.file.LinkOption;  | 
38 |  | -import java.nio.file.Path;  | 
39 |  | -import java.nio.file.Paths;  | 
40 |  | -import java.nio.file.SimpleFileVisitor;  | 
41 |  | -import java.nio.file.StandardCopyOption;  | 
42 |  | -import java.nio.file.attribute.BasicFileAttributes;  | 
43 |  | -import java.nio.file.attribute.FileAttribute;  | 
44 |  | -import java.nio.file.attribute.GroupPrincipal;  | 
45 |  | -import java.nio.file.attribute.PosixFileAttributeView;  | 
46 |  | -import java.nio.file.attribute.PosixFilePermission;  | 
47 |  | -import java.nio.file.attribute.PosixFilePermissions;  | 
48 |  | -import java.nio.file.attribute.UserPrincipal;  | 
49 |  | -import java.nio.file.attribute.UserPrincipalLookupService;  | 
50 |  | -import java.util.ArrayList;  | 
51 |  | -import java.util.EnumSet;  | 
52 |  | -import java.util.HashSet;  | 
53 |  | -import java.util.List;  | 
54 |  | -import java.util.Objects;  | 
55 |  | -import java.util.Set;  | 
 | 28 | +import java.nio.channels.FileChannel;  | 
 | 29 | +import java.nio.file.*;  | 
 | 30 | +import java.nio.file.attribute.*;  | 
 | 31 | +import java.util.*;  | 
56 | 32 | import java.util.concurrent.Callable;  | 
57 | 33 | import java.util.regex.Pattern;  | 
58 | 34 | 
 
  | 
@@ -875,8 +851,16 @@ private BlockingAction<Buffer> readFileInternal(String path) {  | 
875 | 851 |       public Buffer perform() {  | 
876 | 852 |         try {  | 
877 | 853 |           Path target = resolveFile(path).toPath();  | 
878 |  | -          byte[] bytes = Files.readAllBytes(target);  | 
879 |  | -          return Buffer.buffer(bytes);  | 
 | 854 | +          try (FileChannel fc = FileChannel.open(target, StandardOpenOption.READ)) {  | 
 | 855 | +            long size = fc.size();  | 
 | 856 | +            if (size > (long) Integer.MAX_VALUE) {  | 
 | 857 | +              throw new OutOfMemoryError("File is too big");  | 
 | 858 | +            }  | 
 | 859 | +            int len = (int) size;  | 
 | 860 | +            BufferInternal res = BufferInternal.buffer(len);  | 
 | 861 | +            res.unwrap().writeBytes(fc, 0, len);  | 
 | 862 | +            return res;  | 
 | 863 | +          }  | 
880 | 864 |         } catch (IOException e) {  | 
881 | 865 |           throw new FileSystemException(getFileAccessErrorMessage("read", path), e);  | 
882 | 866 |         }  | 
 | 
0 commit comments