{"record":{"id":"885b25cfbb09da11","repo":"apache/hadoop","slug":"encoded-array-component-type-is-not-a-candidate","errorCode":null,"errorMessage":"encoded array component type {} is not a candidate primitive type","messagePattern":"encoded array component type (.+?) is not a candidate primitive type","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/ArrayPrimitiveWritable.java","lineNumber":213,"sourceCode":"      writeDoubleArray(out);\n    } else {\n      throw new IOException(\"Component type \" + componentType.toString()\n          + \" is set as the output type, but no encoding is implemented for this type.\");\n    }\n  }\n\n  /* \n   * @see org.apache.hadoop.io.Writable#readFields(java.io.DataInput)\n   */\n  @Override\n  public void readFields(DataInput in) throws IOException {\n    \n    // read and set the component type of the array\n    @SuppressWarnings(\"deprecation\")\n    String className = UTF8.readString(in);\n    Class<?> componentType = getPrimitiveClass(className);\n    if (componentType == null) {\n      throw new IOException(\"encoded array component type \"\n          + className + \" is not a candidate primitive type\");\n    }\n    checkDeclaredComponentType(componentType);\n    this.componentType = componentType;\n  \n    // read and set the length of the array\n    int length = in.readInt();\n    if (length < 0) {\n      throw new IOException(\"encoded array length is negative \" + length);\n    }\n    this.length = length;\n    \n    // construct and read in the array\n    value = Array.newInstance(componentType, length);\n\n    // do the inner loop.  Walk the decision tree only once.\n    if (componentType == Boolean.TYPE) {             // boolean\n      readBooleanArray(in);","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/ArrayPrimitiveWritable.java#L195-L231","documentation":"During deserialization, readFields() reads the component type name as a UTF8 string and maps it through PRIMITIVE_NAMES. If the name is not one of the eight primitive names, the stream cannot be decoded as a primitive array and an IOException is thrown. This indicates the bytes were not written by ArrayPrimitiveWritable.write(), or the stream is corrupt/misaligned.","triggerScenarios":"Feeding bytes written by a different Writable (e.g. ArrayWritable or a custom type) into readFields(); reading at a wrong offset in a hand-managed buffer; truncation or garbage input; a version change where the wire payload for a field changed type.","commonSituations":"Changing a field's writable class between job versions while old sequence/RPC data is still read; manually slicing shuffle/RPC bytes; endianness or double-read of the same stream position.","solutions":["Verify the reader and writer use the same Writable class and Hadoop version for that field.","Re-generate or migrate the data after changing a serialized field's type.","If parsing raw buffers, confirm the offset/length you pass to the DataInput matches where write() started.","Wrap readFields in IOException handling and quarantine the bad record instead of failing the whole task."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  w.readFields(in);\n} catch (IOException e) {\n  LOG.warn(\"Corrupt or mismatched record at offset \" + offset, e);\n  // skip/quarantine record, or fail the task depending on tolerance\n}","preventionTips":["Keep writer and reader Writable classes and Hadoop versions identical per field.","After changing a serialized field type, regenerate or migrate stored data.","Verify buffer offsets before handing raw bytes to readFields()."],"tags":["hadoop","serialization","deserialization","data-corruption","wire-format"],"backgroundTag":"deserialization-invalid-type","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}