{"record":{"id":"4cf8b290b1734b0f","repo":"apache/flink","slug":"tempdirectories-contains-null-entries","errorCode":null,"errorMessage":"tempDirectories contains null entries","messagePattern":"tempDirectories contains null entries","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/core/fs/RefCountedTmpFileCreator.java","lineNumber":57,"sourceCode":" */\n@Internal\npublic class RefCountedTmpFileCreator\n        implements FunctionWithException<File, RefCountedFileWithStream, IOException> {\n\n    private final File[] tempDirectories;\n\n    private final AtomicInteger next;\n\n    /**\n     * Creates a new TmpReferenceCountedCreator.\n     *\n     * @param tempDirectories The temp directories, not null, and at least one.\n     */\n    private RefCountedTmpFileCreator(File... tempDirectories) {\n        checkArgument(tempDirectories.length > 0, \"tempDirectories must not be empty\");\n        for (File f : tempDirectories) {\n            if (f == null) {\n                throw new IllegalArgumentException(\"tempDirectories contains null entries\");\n            }\n        }\n\n        this.tempDirectories = tempDirectories.clone();\n        this.next = new AtomicInteger(new Random().nextInt(this.tempDirectories.length));\n    }\n\n    /**\n     * Gets the next temp file and stream to temp file. This creates the temp file atomically,\n     * making sure no previous file is overwritten.\n     *\n     * <p>This method is safe against concurrent use.\n     *\n     * @return A pair of temp file and output stream to that temp file.\n     * @throws IOException Thrown, if the stream to the temp file could not be opened.\n     */\n    @Override\n    public RefCountedFileWithStream apply(File file) throws IOException {","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/core/fs/RefCountedTmpFileCreator.java#L39-L75","documentation":"Thrown by RefCountedTmpFileCreator's constructor when one of the supplied temp directory File objects is null. The factory validates that at least one directory is present and that none are null before cloning the array for round-robin allocation.","triggerScenarios":"Constructing RefCountedTmpFileCreator (the factory for ref-counted temp files used by recoverable writers) with a tempDirectories array containing a null entry.","commonSituations":"A config option resolving to null for one of the temp dirs; parsing system temp dirs where one element is missing; programmatic construction passing an uninitialized array slot.","solutions":["Filter out nulls from the temp directory list before constructing: `dirs = Arrays.stream(dirs).filter(Objects::nonNull).toArray(File[]::new)`.","Validate the config source(s) supplying temp directories (e.g. `io.tmp.dirs`, `taskmanager.tmp.dirs`).","Default to System.getProperty(\"java.io.tmpdir\") when a configured dir is unset.","Add a startup check that all resolved temp dirs exist and are non-null."],"exampleFix":"// before\nRefCountedTmpFileCreator creator = RefCountedTmpFileCreator.of(dir1, null, dir3);\n\n// after\nFile[] dirs = new File[] {dir1, dir3};\nRefCountedTmpFileCreator creator = RefCountedTmpFileCreator.of(dirs);","handlingStrategy":"validation","validationCode":"File[] cleanDirs(File... dirs) {\n    File[] filtered = Arrays.stream(dirs)\n        .filter(Objects::nonNull)\n        .toArray(File[]::new);\n    if (filtered.length == 0) throw new IllegalArgumentException(\"no temp dirs\");\n    return filtered;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Filter nulls out of temp dir arrays before constructing the creator.","Resolve temp dirs from a single validated config source.","Default to java.io.tmpdir when a configured dir is absent."],"tags":["filesystem","configuration","validation","temp-dir"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}