{"record":{"id":"8ba4bb4552507a8f","repo":"apache/beam","slug":"error-in-computing-splits-split-is-null-in-inputsplits-list","errorCode":null,"errorMessage":"Error in computing splits, split is null in InputSplits list populated by getSplits() : ","messagePattern":"Error in computing splits, split is null in InputSplits list populated by getSplits\\(\\) : ","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/hadoop-format/src/main/java/org/apache/beam/sdk/io/hadoop/format/HadoopFormatIO.java","lineNumber":804,"sourceCode":"     */\n    @VisibleForTesting\n    void computeSplitsIfNecessary() throws IOException, InterruptedException {\n      if (inputSplits != null) {\n        return;\n      }\n      createInputFormatInstance();\n      List<InputSplit> splits = inputFormatObj.getSplits(Job.getInstance(conf.get()));\n      if (splits == null) {\n        throw new IOException(\"Error in computing splits, getSplits() returns null.\");\n      }\n      if (splits.isEmpty()) {\n        throw new IOException(\"Error in computing splits, getSplits() returns a empty list\");\n      }\n      boundedSourceEstimatedSize = 0;\n      inputSplits = new ArrayList<>();\n      for (InputSplit inputSplit : splits) {\n        if (inputSplit == null) {\n          throw new IOException(\n              \"Error in computing splits, split is null in InputSplits list \"\n                  + \"populated by getSplits() : \");\n        }\n        boundedSourceEstimatedSize += inputSplit.getLength();\n        inputSplits.add(new SerializableSplit(inputSplit));\n      }\n    }\n\n    /**\n     * Creates instance of InputFormat class. The InputFormat class name is specified in the Hadoop\n     * configuration.\n     */\n    @SuppressWarnings(\"WeakerAccess\")\n    protected void createInputFormatInstance() throws IOException {\n      if (inputFormatObj == null) {\n        try {\n          taskAttemptContext = new TaskAttemptContextImpl(conf.get(), new TaskAttemptID());\n          inputFormatObj =","sourceCodeStart":786,"sourceCodeEnd":822,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/hadoop-format/src/main/java/org/apache/beam/sdk/io/hadoop/format/HadoopFormatIO.java#L786-L822","documentation":"HadoopFormatIO's computeSplitsIfNecessary() calls the wrapped Hadoop InputFormat's getSplits() and validates every returned InputSplit. If any element of the list is null, it throws this IOException because a null split cannot be converted to a SerializableSplit or contribute a length to the estimated size.","triggerScenarios":"A user-implemented or buggy InputFormat.getSplits() returns a List<InputSplit> containing null entries; called automatically when split(), getEstimatedSizeBytes(), or a test runner enumerates the BoundedSource for a HadoopFormatIO.read() transform.","commonSituations":"Custom InputFormat implementations that pre-size their splits list (new ArrayList<>(n)) without filling all slots; Hadoop InputFormats that return placeholder nulls when no data matches the filter; wrong InputFormat class configured so its getSplits() is partially initialized.","solutions":["Inspect the InputFormat.getSplits() implementation and ensure it never inserts null elements into the returned list","Verify the configured InputFormat class matches the actual data source (TableInputFormat, TextInputFormat, etc.)","Check that job configuration (paths, table name, filters) is valid so the InputFormat can produce complete splits","If data is legitimately empty, return an empty list instead of a list containing nulls"],"exampleFix":"// before\nList<InputSplit> splits = new ArrayList<>(numSplits);\n// after\nList<InputSplit> splits = new ArrayList<>();\nfor (...) { splits.add(computeSplit(i)); } // never add(null)","handlingStrategy":"validation","validationCode":"List<InputSplit> splits = inputFormat.getSplits(jobConf);\nif (splits == null || splits.stream().anyMatch(Objects::isNull)) {\n  throw new IllegalArgumentException(\"InputFormat returned empty/null splits; check job config and data\");\n}","typeGuard":"static boolean hasNullSplits(List<InputSplit> splits) {\n  return splits == null || splits.stream().anyMatch(Objects::isNull);\n}","tryCatchPattern":"try {\n  source.split(desiredSize, options);\n} catch (IOException e) {\n  if (e.getMessage().contains(\"split is null\")) {\n    throw new IllegalStateException(\"Bad InputFormat: getSplits() produced null entries\", e);\n  }\n  throw e;\n}","preventionTips":["Unit-test custom InputFormat.getSplits() to assert no null entries","Return an empty list for genuinely empty data, never nulls","Log the split list size and contents before handing it to Beam"],"tags":["hadoop","inputformat","null-pointer","split-computation"],"backgroundTag":"null-argument","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}