{"record":{"id":"c4962f43b672141f","repo":"apache/flink","slug":"hadoop-input-split-must-not-be-null","errorCode":null,"errorMessage":"Hadoop input split must not be null","messagePattern":"Hadoop input split must not be null","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapred/wrapper/HadoopInputSplit.java","lineNumber":58,"sourceCode":"@Internal\npublic class HadoopInputSplit extends LocatableInputSplit {\n\n    private static final long serialVersionUID = -6990336376163226160L;\n\n    private final Class<? extends org.apache.hadoop.mapred.InputSplit> splitType;\n\n    private transient org.apache.hadoop.mapred.InputSplit hadoopInputSplit;\n\n    @Nullable private transient JobConf jobConf;\n\n    public HadoopInputSplit(\n            int splitNumber,\n            org.apache.hadoop.mapred.InputSplit hInputSplit,\n            @Nullable JobConf jobconf) {\n        super(splitNumber, (String) null);\n\n        if (hInputSplit == null) {\n            throw new NullPointerException(\"Hadoop input split must not be null\");\n        }\n\n        if (needsJobConf(hInputSplit) && jobconf == null) {\n            throw new NullPointerException(\n                    \"Hadoop JobConf must not be null when input split is configurable.\");\n        }\n\n        this.splitType = hInputSplit.getClass();\n\n        this.jobConf = jobconf;\n        this.hadoopInputSplit = hInputSplit;\n    }\n\n    // ------------------------------------------------------------------------\n    //  Properties\n    // ------------------------------------------------------------------------\n\n    @Override","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapred/wrapper/HadoopInputSplit.java#L40-L76","documentation":"Thrown by the HadoopInputSplit constructor when the hadoop InputSplit argument is null. A null InputSplit has no split data to read from, so the constructor rejects it immediately rather than failing later during reads. This is a programmer error in code that constructs HadoopInputSplit objects.","triggerScenarios":"Constructing a new HadoopInputSplit(splitNumber, null, jobConf) — typically in custom input format wrappers or test code that fails to obtain a real InputSplit from Hadoop's getSplits().","commonSituations":"Hadoop InputFormat.getSplits() returning null instead of an empty list; custom wrapper code that passes through a null split; test fixtures that forget to populate the split.","solutions":["Ensure the Hadoop InputSplit passed to HadoopInputSplit is non-null — check the return of getSplits() before wrapping.","If getSplits() can legitimately return no splits, handle the empty case before constructing HadoopInputSplit objects.","Add a null check in the calling code before constructing the split wrapper."],"exampleFix":"// before\norg.apache.hadoop.mapred.InputSplit hadoopSplit = format.getSplits(jobConf, 0).get(0);\nHadoopInputSplit split = new HadoopInputSplit(0, hadoopSplit, jobConf);\n// after\nInputSplit[] splits = format.getSplits(jobConf, numSplits);\nif (splits == null || splits.length == 0) {\n    throw new IllegalStateException(\"Hadoop InputFormat returned no splits\");\n}\nHadoopInputSplit split = new HadoopInputSplit(0, splits[0], jobConf);","handlingStrategy":"validation","validationCode":"// Validate InputSplit is non-null before constructing HadoopInputSplit\nObjects.requireNonNull(hInputSplit, \"Hadoop InputSplit must not be null\");\nif (hInputSplit == null) {\n    throw new NullPointerException(\"Hadoop InputSplit from getSplits() is null\");\n}\nHadoopInputSplit split = new HadoopInputSplit(splitNumber, hInputSplit, jobConf);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always null-check the InputSplit returned by Hadoop's getSplits() before wrapping.","Handle the empty-splits case explicitly rather than indexing into the array.","Use Objects.requireNonNull in wrapper code for early failure."],"tags":["hadoop-compatibility","input-split","null-check","internal-api"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}