{"record":{"id":"e3df2d0616aebfac","repo":"apache/hadoop","slug":"wrong-writable-class-given","errorCode":null,"errorMessage":"wrong Writable class given","messagePattern":"wrong Writable class given","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-streaming/src/main/java/org/apache/hadoop/typedbytes/TypedBytesWritableInput.java","lineNumber":367,"sourceCode":"  public <K extends WritableComparable<? super K>> SortedMapWritable<K>\n    readSortedMap() throws IOException {\n    return readSortedMap((SortedMapWritable<K>)null);\n  }\n  \n  public Writable readWritable(Writable writable) throws IOException {\n    ByteArrayInputStream bais = new ByteArrayInputStream(in.readBytes());\n    DataInputStream dis = new DataInputStream(bais);\n    String className = WritableUtils.readString(dis);\n    if (writable == null) {\n      try {\n        Class<? extends Writable> cls = \n          conf.getClassByName(className).asSubclass(Writable.class);\n        writable = (Writable) ReflectionUtils.newInstance(cls, conf);\n      } catch (ClassNotFoundException e) {\n        throw new IOException(e);\n      }\n    } else if (!writable.getClass().getName().equals(className)) {\n      throw new IOException(\"wrong Writable class given\");\n    }\n    writable.readFields(dis);\n    return writable;\n  }\n\n  public Writable readWritable() throws IOException {\n    return readWritable(null);\n  }\n\n  public Configuration getConf() {\n    return conf;\n  }\n\n  public void setConf(Configuration conf) {\n    this.conf = conf;\n  }\n  \n}","sourceCodeStart":349,"sourceCodeEnd":385,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-streaming/src/main/java/org/apache/hadoop/typedbytes/TypedBytesWritableInput.java#L349-L385","documentation":"Error \"wrong Writable class given\" thrown in apache/hadoop.","triggerScenarios":"TypedBytesWritableInput is asked to read a Writable into an instance whose class does not match the expected Writable type.","commonSituations":"See trigger scenarios.","solutions":["Pass the Writable class that matches the data actually written in the typedbytes stream."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}