{"record":{"id":"249821c2a296af8d","repo":"apache/hadoop","slug":"null-reporter-has-no-input","errorCode":null,"errorMessage":"NULL reporter has no input","messagePattern":"NULL reporter has no input","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/Reporter.java","lineNumber":65,"sourceCode":"   * A constant of Reporter type that does nothing.\n   */\n  public static final Reporter NULL = new Reporter() {\n      public void setStatus(String s) {\n      }\n      public void progress() {\n      }\n      public Counter getCounter(Enum<?> name) {\n        return null;\n      }\n      public Counter getCounter(String group, String name) {\n        return null;\n      }\n      public void incrCounter(Enum<?> key, long amount) {\n      }\n      public void incrCounter(String group, String counter, long amount) {\n      }\n      public InputSplit getInputSplit() throws UnsupportedOperationException {\n        throw new UnsupportedOperationException(\"NULL reporter has no input\");\n      }\n      @Override\n      public float getProgress() {\n        return 0;\n      }\n    };\n\n  /**\n   * Set the status description for the task.\n   * \n   * @param status brief description of the current status.\n   */\n  public abstract void setStatus(String status);\n  \n  /**\n   * Get the {@link Counter} of the given group with the given name.\n   * \n   * @param name counter name","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/Reporter.java#L47-L83","documentation":"Reporter.NULL is a stateless no-op singleton used where no real Reporter exists (tests, utility code, wrapped jobs): its counter methods return null or do nothing. Its getInputSplit() deliberately throws UnsupportedOperationException because a NULL reporter has no task input associated with it. Any code path that reaches getInputSplit() through Reporter.NULL is a programming error.","triggerScenarios":"Calling Reporter.NULL.getInputSplit(); passing Reporter.NULL into library code that later asks for the split; unit tests exercising old-API map/reduce methods with Reporter.NULL where the code under test calls reporter.getInputSplit().","commonSituations":"Mappers written against the old API that fetch the FileSplit for the input path, executed in unit tests or reduce-side wrappers where Reporter.NULL was supplied; helper utilities that accept a Reporter for progress but also try to read the split.","solutions":["Only call getInputSplit() on the live Reporter instance passed into map() by the framework.","Pass the split explicitly (constructor or configuration) to helpers that need it, instead of extracting it from the reporter.","In the new API use Mapper.Context.getInputSplit() inside map(), which is always populated for map tasks."],"exampleFix":"// before\nFileSplit fs = (FileSplit) reporter.getInputSplit(); // reporter may be Reporter.NULL\n\n// after\nif (reporter != null && reporter != Reporter.NULL) {\n  FileSplit fs = (FileSplit) reporter.getInputSplit();\n} else {\n  // obtain split from job configuration or context instead\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static boolean reporterHasInputSplit(Reporter r) {\n  return r != null && r != Reporter.NULL;\n}","tryCatchPattern":null,"preventionTips":["Only read the split from the Reporter passed into map() by the framework.","Pass split metadata to helpers via parameters or job configuration, not via Reporter.","In new-API code use Context.getInputSplit() inside map() instead."],"tags":["hadoop","mapreduce","reporter","null-object","unsupported-operation"],"backgroundTag":"null-object-misuse","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}