{"record":{"id":"6f0935cb26a86de2","repo":"apache/flink","slug":"hadoop-input-split-must-not-be-null-6f0935","errorCode":null,"errorMessage":"Hadoop input split must not be null","messagePattern":"Hadoop input split must not be null","errorType":"validation","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapreduce/wrapper/HadoopInputSplit.java","lineNumber":53,"sourceCode":" * InputSplit}.\n */\n@Internal\npublic class HadoopInputSplit extends LocatableInputSplit {\n\n    private static final long serialVersionUID = 6119153593707857235L;\n\n    private final Class<? extends org.apache.hadoop.mapreduce.InputSplit> splitType;\n\n    private transient org.apache.hadoop.mapreduce.InputSplit mapreduceInputSplit;\n\n    public HadoopInputSplit(\n            int splitNumber,\n            org.apache.hadoop.mapreduce.InputSplit mapreduceInputSplit,\n            JobContext jobContext) {\n        super(splitNumber, (String) null);\n\n        if (mapreduceInputSplit == null) {\n            throw new NullPointerException(\"Hadoop input split must not be null\");\n        }\n        if (!(mapreduceInputSplit instanceof Writable)) {\n            throw new IllegalArgumentException(\"InputSplit must implement Writable interface.\");\n        }\n        this.splitType = mapreduceInputSplit.getClass();\n        this.mapreduceInputSplit = mapreduceInputSplit;\n    }\n\n    // ------------------------------------------------------------------------\n    //  Properties\n    // ------------------------------------------------------------------------\n\n    public org.apache.hadoop.mapreduce.InputSplit getHadoopInputSplit() {\n        return mapreduceInputSplit;\n    }\n\n    @Override\n    public String[] getHostnames() {","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapreduce/wrapper/HadoopInputSplit.java#L35-L71","documentation":"Thrown by the mapreduce-API HadoopInputSplit constructor when the wrapped InputSplit argument is null. This is a defensive precondition: a null split cannot be serialized via the Writable protocol the wrapper depends on, so construction refuses it immediately rather than NPE'ing later during write/read.","triggerScenarios":"Produced when new HadoopInputSplit(splitNumber, mapreduceInputSplit, jobContext) is called with mapreduceInputSplit == null — e.g. Hadoop's InputFormat.getSplits() returned a list containing a null element, or user code constructed the wrapper with a null split.","commonSituations":"A buggy/custom InputFormat whose getSplits() emits null entries; a wrapper built manually in tests with a null split; upstream split list corruption where a split entry failed to initialize.","solutions":["Ensure the Hadoop InputFormat.getSplits() never returns null entries; filter or reject nulls at the source.","Guard construction sites that build HadoopInputSplit so a null split is logged and skipped rather than wrapped.","If the null comes from a third-party InputFormat, patch or wrap it to never emit null splits.","In tests, always pass a real (or mocked, non-null) InputSplit to the constructor."],"exampleFix":"// before\nfor (InputSplit s : splits) {\n    hadoopInputSplits[i] = new HadoopInputSplit(i, s, jobContext);\n}\n// after — skip null splits defensively\nfor (InputSplit s : splits) {\n    if (s == null) continue;\n    hadoopInputSplits[i++] = new HadoopInputSplit(i, s, jobContext);\n}","handlingStrategy":"validation","validationCode":"// Before constructing the wrapper, assert the split is non-null\nif (mapreduceInputSplit == null) {\n    throw new IllegalArgumentException(\"Refusing to wrap a null Hadoop InputSplit\");\n}\nnew HadoopInputSplit(splitNumber, mapreduceInputSplit, jobContext);","typeGuard":"java.util.Objects.requireNonNull(mapreduceInputSplit, \"Hadoop InputSplit must not be null\")","tryCatchPattern":null,"preventionTips":["Filter null entries from getSplits() results before wrapping.","Guard construction sites with Objects.requireNonNull.","In tests, always pass a real or stubbed non-null split.","Patch third-party InputFormats that emit null splits."],"tags":["hadoop","mapreduce","validation","constructor","input-split"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}