{"record":{"id":"745e15af68138347","repo":"apache/flink","slug":"inputsplit-must-implement-writable-interface","errorCode":null,"errorMessage":"InputSplit must implement Writable interface.","messagePattern":"InputSplit must implement Writable interface\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapreduce/wrapper/HadoopInputSplit.java","lineNumber":56,"sourceCode":"public class HadoopInputSplit extends LocatableInputSplit {\n\n    private static final long serialVersionUID = 6119153593707857235L;\n\n    private final Class<? extends org.apache.hadoop.mapreduce.InputSplit> splitType;\n\n    private transient org.apache.hadoop.mapreduce.InputSplit mapreduceInputSplit;\n\n    public HadoopInputSplit(\n            int splitNumber,\n            org.apache.hadoop.mapreduce.InputSplit mapreduceInputSplit,\n            JobContext jobContext) {\n        super(splitNumber, (String) null);\n\n        if (mapreduceInputSplit == null) {\n            throw new NullPointerException(\"Hadoop input split must not be null\");\n        }\n        if (!(mapreduceInputSplit instanceof Writable)) {\n            throw new IllegalArgumentException(\"InputSplit must implement Writable interface.\");\n        }\n        this.splitType = mapreduceInputSplit.getClass();\n        this.mapreduceInputSplit = mapreduceInputSplit;\n    }\n\n    // ------------------------------------------------------------------------\n    //  Properties\n    // ------------------------------------------------------------------------\n\n    public org.apache.hadoop.mapreduce.InputSplit getHadoopInputSplit() {\n        return mapreduceInputSplit;\n    }\n\n    @Override\n    public String[] getHostnames() {\n        try {\n            return mapreduceInputSplit.getLocations();\n        } catch (Exception e) {","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapreduce/wrapper/HadoopInputSplit.java#L38-L74","documentation":"Thrown by the mapreduce-API HadoopInputSplit constructor when the wrapped InputSplit does not implement Hadoop's Writable interface. The wrapper serializes the split across the network via the Writable protocol (write/readFields), so a non-Writable split cannot be shipped to TaskManagers and construction rejects it.","triggerScenarios":"Produced when new HadoopInputSplit(splitNumber, mapreduceInputSplit, jobContext) is given a mapreduceInputSplit that is not instanceof Writable — e.g. a custom InputSplit that omits org.apache.hadoop.io.Writable, or a split from an InputFormat that uses a non-Writable split type (incompatible with this wrapper).","commonSituations":"A custom mapreduce InputSplit implemented without extending/implementing Writable; using a newer Hadoop API split that is not Writable; misunderstanding that Flink's mapreduce wrapper only supports Writable splits (unlike the mapred wrapper, which uses WritableFactories on mapred.InputSplit).","solutions":["Make the custom InputSplit class implement org.apache.hadoop.io.Writable (provide write and readFields).","Use a built-in Hadoop split type (e.g. FileSplit) which already implements Writable.","If the InputFormat only produces non-Writable splits, wrap/adapt the split or choose a different InputFormat compatible with the Writable requirement.","Verify the split instance passed to the constructor is the concrete Writable type, not a raw interface."],"exampleFix":"// before — split not Writable\npublic class MySplit extends org.apache.hadoop.mapreduce.InputSplit {\n    // missing write/readFields\n}\n// after — implement Writable\npublic class MySplit extends org.apache.hadoop.mapreduce.InputSplit\n        implements org.apache.hadoop.io.Writable {\n    @Override public void write(DataOutput out) throws IOException { ... }\n    @Override public void readFields(DataInput in) throws IOException { ... }\n}","handlingStrategy":"type-guard","validationCode":"// Before constructing the wrapper, assert the split is Writable\nif (!(mapreduceInputSplit instanceof org.apache.hadoop.io.Writable)) {\n    throw new IllegalArgumentException(\"InputSplit \" + mapreduceInputSplit.getClass().getName()\n        + \" must implement org.apache.hadoop.io.Writable to be shipped by Flink\");\n}\nnew HadoopInputSplit(splitNumber, mapreduceInputSplit, jobContext);","typeGuard":"mapreduceInputSplit instanceof org.apache.hadoop.io.Writable","tryCatchPattern":null,"preventionTips":["Ensure custom mapreduce InputSplits implement Writable (write + readFields).","Prefer built-in Writable splits (e.g. FileSplit).","Type-check the split before wrapping to fail with a clearer message.","Remember the mapreduce wrapper requires Writable, unlike some mapred paths."],"tags":["hadoop","mapreduce","validation","writable","input-split"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}