{"record":{"id":"cfebd1fe72ae94c6","repo":"apache/hadoop","slug":"uninitialized-inputsplit","errorCode":null,"errorMessage":"Uninitialized InputSplit","messagePattern":"Uninitialized InputSplit","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/join/CompositeInputSplit.java","lineNumber":58,"sourceCode":"\n  private int fill = 0;\n  private long totsize = 0L;\n  private InputSplit[] splits;\n\n  public CompositeInputSplit() { }\n\n  public CompositeInputSplit(int capacity) {\n    splits = new InputSplit[capacity];\n  }\n\n  /**\n   * Add an InputSplit to this collection.\n   * @throws IOException If capacity was not specified during construction\n   *                     or if capacity has been reached.\n   */\n  public void add(InputSplit s) throws IOException {\n    if (null == splits) {\n      throw new IOException(\"Uninitialized InputSplit\");\n    }\n    if (fill == splits.length) {\n      throw new IOException(\"Too many splits\");\n    }\n    splits[fill++] = s;\n    totsize += s.getLength();\n  }\n\n  /**\n   * Get ith child InputSplit.\n   */\n  public InputSplit get(int i) {\n    return splits[i];\n  }\n\n  /**\n   * Return the aggregate length of all child InputSplits currently added.\n   */","sourceCodeStart":40,"sourceCodeEnd":76,"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/join/CompositeInputSplit.java#L40-L76","documentation":"CompositeInputSplit holds N child splits for a join; the array is only allocated by the capacity constructor (or by readFields during deserialization). The no-arg constructor — meant for Writable deserialization — leaves splits null, and add() then throws this IOException ('Uninitialized InputSplit') before the capacity check ('Too many splits') can even run. Calling add() on a freshly reflect-constructed instance is the classic trigger.","triggerScenarios":"new CompositeInputSplit() followed by add(split); a join framework (CompositeRecordReader) built with an arity/capacity mismatch so the split is never sized; reflection-based factories that use the default constructor.","commonSituations":"Hand-rolled map-side join plumbing; copy-pasted examples that drop the capacity argument; serializers that deserialize into a properly sized instance but user code that constructs one manually.","solutions":["Always construct with the join arity: new CompositeInputSplit(2) for a two-way join.","When building via a framework, ensure the join expression's arity and the split capacity agree.","Instances obtained via readFields are already sized — never reuse a no-arg instance for manual population."],"exampleFix":"// before\nCompositeInputSplit split = new CompositeInputSplit();\nsplit.add(leftSplit); // throws\n\n// after\nCompositeInputSplit split = new CompositeInputSplit(2);\nsplit.add(leftSplit);\nsplit.add(rightSplit);","handlingStrategy":"validation","validationCode":"// always size the composite split to the join arity before adding\nint arity = 2; // number of join inputs\nCompositeInputSplit split = new CompositeInputSplit(arity);\nif (splitCount == arity) throw new IOException(\"Too many splits\");","typeGuard":"static boolean isInitialized(CompositeInputSplit s) {\n  // no public accessor; treat any instance from new CompositeInputSplit() as uninitialized\n  return wasConstructedWithCapacity; // track construction site in your own wrapper\n}","tryCatchPattern":"try {\n  split.add(child);\n} catch (IOException e) {\n  if (e.getMessage().equals(\"Uninitialized InputSplit\")) {\n    throw new IllegalStateException(\"Construct with new CompositeInputSplit(arity)\", e);\n  }\n  throw e;\n}","preventionTips":["Always pass capacity: new CompositeInputSplit(n) matching the number of join inputs.","Reserve the no-arg constructor for Writable deserialization only.","When using join frameworks, keep the join expression arity and split capacity consistent."],"tags":["hadoop","mapreduce","join","input-split","initialization"],"backgroundTag":"uninitialized-object-state","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}