{"record":{"id":"291ccfae1411ecff","repo":"apache/flink","slug":"name-must-not-be-null","errorCode":null,"errorMessage":"name must not be null","messagePattern":"name must not be null","errorType":"validation","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/cache/DistributedCache.java","lineNumber":145,"sourceCode":"                    + \", blobKey=\"\n                    + Arrays.toString(blobKey)\n                    + '}';\n        }\n    }\n\n    // ------------------------------------------------------------------------\n\n    private final Map<String, Future<Path>> cacheCopyTasks;\n\n    public DistributedCache(Map<String, Future<Path>> cacheCopyTasks) {\n        this.cacheCopyTasks = cacheCopyTasks;\n    }\n\n    // ------------------------------------------------------------------------\n\n    public File getFile(String name) {\n        if (name == null) {\n            throw new NullPointerException(\"name must not be null\");\n        }\n\n        Future<Path> future = cacheCopyTasks.get(name);\n        if (future == null) {\n            throw new IllegalArgumentException(\n                    \"File with name '\"\n                            + name\n                            + \"' is not available.\"\n                            + \" Did you forget to register the file?\");\n        }\n\n        try {\n            final Path path = future.get();\n            URI tmp = path.makeQualified(path.getFileSystem()).toUri();\n            return new File(tmp);\n        } catch (ExecutionException e) {\n            throw new RuntimeException(\"An error occurred while copying the file.\", e.getCause());\n        } catch (Exception e) {","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/cache/DistributedCache.java#L127-L163","documentation":"Thrown by DistributedCache.getFile(name) when name is null. In a task, getFile resolves a previously registered distributed-cache file by its logical name; null has no mapping and would NPE in the map lookup, so the API rejects it up front. It indicates a caller bug — the name should come from the operator's registered cache entries.","triggerScenarios":"Calling getRuntimeContext().getDistributedCache().getFile(null); passing a config-derived name that resolved to null.","commonSituations":"Operator open() methods that look up a cache file via a field that was never set; generic code that iterates cache names where one entry had a null key.","solutions":["Ensure the name passed to getFile matches a name previously registered via registerCachedFile on the ExecutionEnvironment/Plan.","Null-check the name variable before calling getFile and surface a clear error pointing at the missing registration.","Source cache names from a fixed, validated set rather than runtime-computed strings."],"exampleFix":"// before\nFile f = getRuntimeContext().getDistributedCache().getFile(cacheName);\n// after\nif (cacheName == null) {\n    throw new IllegalStateException(\"cache file name not configured for this operator\");\n}\nFile f = getRuntimeContext().getDistributedCache().getFile(cacheName);","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(name, \"cache file name\");\ngetRuntimeContext().getDistributedCache().getFile(name);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure the name was registered via registerCachedFile before lookup.","Null-check the name field in operator open() before getFile.","Source cache names from a fixed, validated set."],"tags":["distributed-cache","null-check","task","runtime-context"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}