{"record":{"id":"0c9f49b6b8991813","repo":"eclipse-vertx/vert.x","slug":"failed-to-create-p","errorCode":null,"errorMessage":"Failed to create ${p}","messagePattern":"Failed to create (.+?)","errorType":"exception","errorClass":"FileSystemException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/file/impl/FileSystemImpl.java","lineNumber":921,"sourceCode":"\n  private BlockingAction<Void> createFileInternal(String path) {\n    return createFileInternal(path, null);\n  }\n\n  protected BlockingAction<Void> createFileInternal(String p, String perms) {\n    Objects.requireNonNull(p);\n    FileAttribute<?> attrs = perms == null ? null : PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString(perms));\n    return new BlockingAction<Void>() {\n      public Void perform() {\n        try {\n          Path target = resolveFile(p).toPath();\n          if (attrs != null) {\n            Files.createFile(target, attrs);\n          } else {\n            Files.createFile(target);\n          }\n        } catch (IOException e) {\n          throw new FileSystemException(getFileAccessErrorMessage(\"create\", p), e);\n        }\n        return null;\n      }\n    };\n  }\n\n  private BlockingAction<Boolean> existsInternal(String path) {\n    Objects.requireNonNull(path);\n    return new BlockingAction<Boolean>() {\n      public Boolean perform() {\n        File file = resolveFile(path);\n        return file.exists();\n      }\n    };\n  }\n\n  private BlockingAction<FileSystemProps> fsPropsInternal(String path) {\n    Objects.requireNonNull(path);","sourceCodeStart":903,"sourceCodeEnd":939,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/file/impl/FileSystemImpl.java#L903-L939","documentation":"Wrapped error in createFileInternal: Files.createFile (with or without POSIX attributes) threw an IOException, typically because the file already exists or the parent directory is missing. The raw path is reported and the concrete cause is attached.","triggerScenarios":"Calling FileSystem.createFile(path) or createFile(path, attrs) when the parent directory does not exist, permission is denied, or the file already exists (NoSuchFileException/FileAlreadyExistsException are IOExceptions too).","commonSituations":"Creating marker/lock files in directories that were never created, race conditions where the file already exists, or writing into read-only locations.","solutions":["Check for existing files first or handle FileAlreadyExistsException from the cause","Create parent directories before creating the file","Verify write permissions"],"exampleFix":"// before\nvertx.fileSystem().createFile(\"locks/job.lock\");\n// after\nvertx.fileSystem().mkdirs(\"locks\")\n  .compose(v -> vertx.fileSystem().createFile(\"locks/job.lock\"));","handlingStrategy":"try-catch","validationCode":"Path target = Path.of(path);\nif (Files.exists(target)) {\n  // decide: skip or delete first\n} else if (!Files.isDirectory(target.getParent())) {\n  Files.createDirectories(target.getParent());\n}","typeGuard":null,"tryCatchPattern":"try {\n  fs.createFile(path);\n} catch (FileSystemException e) {\n  if (e.getCause() instanceof java.nio.file.FileAlreadyExistsException) {\n    // treat as success or delete-and-recreate\n  } else {\n    logger.error(\"createFile failed: {}\", e.getCause());\n  }\n}","preventionTips":["Check existence first for idempotent creation","Create parent directories beforehand","Run as a user with write access to the target directory"],"tags":["filesystem","io","create"],"backgroundTag":"file-write-failed","analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}