{"record":{"id":"a2179b3721fe7f22","repo":"apache/beam","slug":"null-recordreader-object-returned-by-s","errorCode":null,"errorMessage":"Null RecordReader object returned by %s","messagePattern":"Null RecordReader object returned by (.+?)","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":935,"sourceCode":"      public HadoopInputFormatBoundedSource<K, V> getCurrentSource() {\n        return source;\n      }\n\n      @Override\n      public boolean start() throws IOException {\n        try {\n          recordsReturned.set(0L);\n          recordReader = inputFormatObj.createRecordReader(split.getSplit(), taskAttemptContext);\n          if (recordReader != null) {\n            recordReader.initialize(split.getSplit(), taskAttemptContext);\n            progressValue.set(getProgress());\n            if (recordReader.nextKeyValue()) {\n              recordsReturned.incrementAndGet();\n              doneReading = false;\n              return true;\n            }\n          } else {\n            throw new IOException(\n                String.format(\n                    \"Null RecordReader object returned by %s\", inputFormatObj.getClass()));\n          }\n          recordReader = null;\n        } catch (InterruptedException e) {\n          throw new IOException(\n              \"Could not read because the thread got interrupted while \"\n                  + \"reading the records with an exception: \",\n              e);\n        }\n        doneReading = true;\n        return false;\n      }\n\n      @Override\n      public boolean advance() throws IOException {\n        try {\n          progressValue.set(getProgress());","sourceCodeStart":917,"sourceCodeEnd":953,"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#L917-L953","documentation":"HadoopInputFormatReader's readNext, after exhausting the current RecordReader, asks the InputFormat for a RecordReader for the next split. If the InputFormat returns null instead of a RecordReader, this IOException is thrown, since the reader cannot proceed.","triggerScenarios":"The configured InputFormat.getRecordReader() returns null for a split — typically a custom/buggy InputFormat or one that cannot handle the given SerializableSplit.","commonSituations":"Custom InputFormat whose getRecordReader() silently returns null on unsupported splits or on configuration problems; misconfigured record reader class in the job conf.","solutions":["Fix the InputFormat.getRecordReader() to throw a descriptive IOException instead of returning null","Ensure the record reader class set in the job configuration is valid and loadable","Verify the InputFormat supports all splits produced by its getSplits()"],"exampleFix":"// before\npublic RecordReader<K,V> getRecordReader(...) { if (bad) return null; ... }\n// after\npublic RecordReader<K,V> getRecordReader(...) { if (bad) throw new IOException(\"No record reader for split\"); ... }","handlingStrategy":"validation","validationCode":"RecordReader<?,?> rr = inputFormat.getRecordReader(split, conf, reporter);\nif (rr == null) throw new IOException(\"InputFormat returned null RecordReader for split \" + split);","typeGuard":null,"tryCatchPattern":"try {\n  while (reader.advance()) { ... }\n} catch (IOException e) {\n  if (e.getMessage().startsWith(\"Null RecordReader object returned by\")) {\n    throw new IllegalStateException(\"Fix InputFormat.getRecordReader(): it must not return null\", e);\n  }\n  throw e;\n}","preventionTips":["Never return null from getRecordReader(); throw a descriptive IOException instead","Test the InputFormat with every split produced by getSplits()","Confirm the record reader class configured in the job conf exists"],"tags":["hadoop","recordreader","null-pointer","inputformat"],"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"}