{"record":{"id":"0a12df42acc5abc1","repo":"eclipse-vertx/vert.x","slug":"file-is-too-big","errorCode":null,"errorMessage":"File is too big","messagePattern":"File is too big","errorType":"exception","errorClass":"OutOfMemoryError","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/file/impl/FileSystemImpl.java","lineNumber":859,"sourceCode":"          }\n        } catch (IOException e) {\n          throw new FileSystemException(getFolderAccessErrorMessage(\"read\", p), e);\n        }\n      }\n    };\n  }\n\n  private BlockingAction<Buffer> readFileInternal(String path) {\n    Objects.requireNonNull(path);\n    return new BlockingAction<Buffer>() {\n      public Buffer perform() {\n        try {\n          Path target = resolveFile(path).toPath();\n          try (FileChannel fc = FileChannel.open(target, StandardOpenOption.READ)) {\n            long size = fc.size();\n            if (size > (long) Integer.MAX_VALUE) {\n              // Throwing OOM as Files#readAllLines would in this case\n              throw new OutOfMemoryError(\"File is too big\");\n            }\n            int len = (int) size;\n            BufferInternal res = BufferInternal.buffer(len);\n            res.unwrap().writeBytes(fc, 0, len);\n            return res;\n          }\n        } catch (IOException e) {\n          throw new FileSystemException(getFileAccessErrorMessage(\"read\", path), e);\n        }\n      }\n    };\n  }\n\n  private BlockingAction<Void> writeFileInternal(String path, Buffer data) {\n    Objects.requireNonNull(path);\n    Objects.requireNonNull(data);\n    return new BlockingAction<Void>() {\n      public Void perform() {","sourceCodeStart":841,"sourceCodeEnd":877,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/file/impl/FileSystemImpl.java#L841-L877","documentation":"Thrown (deliberately as OutOfMemoryError, mirroring what Files.readAllBytes would induce) when readFile attempts to load a file larger than Integer.MAX_VALUE bytes into a Buffer. Vert.x buffers are int-indexed, so files over ~2GB cannot be read whole.","triggerScenarios":"Calling FileSystem.readFile(path) on a file whose size exceeds 2,147,483,647 bytes.","commonSituations":"Reading large log files, data exports, or video/binary assets with readFile instead of streaming them via openFile/AsyncFile.","solutions":["Use FileSystem.open with OpenOptions read+buffer and stream the file via AsyncFile in chunks","Use FileSystem.readFile only for files known to be small; check size first with FileSystem.props(path).size()","Process the file line-by-line or block-by-block rather than materializing it in memory"],"exampleFix":"// before\nvertx.fileSystem().readFile(\"huge.dat\");\n// after\nvertx.fileSystem().open(\"huge.dat\", new OpenOptions().setRead(true))\n  .onSuccess(file -> file.pipeTo(readStream -> ...)); // stream in chunks","handlingStrategy":"validation","validationCode":"io.vertx.core.file.FileProps props = vertx.fileSystem().propsBlocking(path);\nif (props.size() > Integer.MAX_VALUE) {\n  throw new IllegalStateException(\"File too large to buffer: \" + path);\n}","typeGuard":null,"tryCatchPattern":"try {\n  fs.readFile(path);\n} catch (OutOfMemoryError e) {\n  if (\"File is too big\".equals(e.getMessage())) {\n    // fall back to streaming via AsyncFile\n  }\n}","preventionTips":["Check file size with FileSystem.props before readFile","Stream large files with FileSystem.open + AsyncFile instead of buffering","Set an application-level max-file-size policy for inputs"],"tags":["filesystem","memory","limit"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}