{"record":{"id":"986e584a73754368","repo":"apache/flink","slug":"unrecognized-type-this-method-is-deprecated-and-m","errorCode":null,"errorMessage":"Unrecognized type. This method is deprecated and might not work for all supported types.","messagePattern":"Unrecognized type\\. This method is deprecated and might not work for all supported types\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/configuration/Configuration.java","lineNumber":629,"sourceCode":"                } else if (clazz == Long.class) {\n                    out.write(TYPE_LONG);\n                    out.writeLong((Long) val);\n                } else if (clazz == Float.class) {\n                    out.write(TYPE_FLOAT);\n                    out.writeFloat((Float) val);\n                } else if (clazz == Double.class) {\n                    out.write(TYPE_DOUBLE);\n                    out.writeDouble((Double) val);\n                } else if (clazz == byte[].class) {\n                    out.write(TYPE_BYTES);\n                    byte[] bytes = (byte[]) val;\n                    out.writeInt(bytes.length);\n                    out.write(bytes);\n                } else if (clazz == Boolean.class) {\n                    out.write(TYPE_BOOLEAN);\n                    out.writeBoolean((Boolean) val);\n                } else {\n                    throw new IllegalArgumentException(\n                            \"Unrecognized type. This method is deprecated and might not work\"\n                                    + \" for all supported types.\");\n                }\n            }\n        }\n    }\n\n    // --------------------------------------------------------------------------------------------\n\n    @Override\n    public int hashCode() {\n        int hash = 0;\n        for (String s : this.confData.keySet()) {\n            hash ^= s.hashCode();\n        }\n        return hash;\n    }\n","sourceCodeStart":611,"sourceCodeEnd":647,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/configuration/Configuration.java#L611-L647","documentation":"The write counterpart of the legacy binary Configuration format: writeToStream() emits each entry with a type tag and only knows String/Integer/Long/Double/byte[]/Boolean (plus a few handled earlier). Any other value class stored in confData throws IllegalArgumentException 'Unrecognized type...'. It is a deprecated path — modern keys/values (durations, memory sizes, lists, maps) stored via the typed API will trip it if this writer is used.","triggerScenarios":"Storing a non-primitive value (Duration, MemorySize, List, Map, enum) via conf.set(...) / setData and then serializing with this legacy writeToStream; internal code paths still calling the deprecated writer on modern typed values.","commonSituations":"Legacy code embedding arbitrary objects into Configuration; Flink internal migration where a modern option's parsed value lands in confData and an old writer serializes it; user extensions putting custom objects into Configuration.","solutions":["Store only the supported primitive types (String, Integer, Long, Double, Boolean, byte[]) if this serialization path must be used.","Encode complex values as strings and parse them after readback.","Migrate off the deprecated writeToStream/readFields pair to the current Configuration serialization utilities."],"exampleFix":"// before\nconf.set(\"job.duration\", Duration.ofSeconds(30)); // later writeToStream -> IllegalArgumentException\n\n// after\nconf.set(\"job.duration\", \"30 s\");","handlingStrategy":"type-guard","validationCode":"static boolean legacyWritable(Configuration conf) {\n    synchronized (conf.confData) {\n        return conf.confData.values().stream()\n            .allMatch(v -> v == null || v instanceof String || v instanceof Integer\n                || v instanceof Long || v instanceof Double || v instanceof Boolean\n                || v instanceof byte[]);\n    }\n}","typeGuard":"boolean isLegacySerializableValue(Object v) {\n    return v instanceof String || v instanceof Integer || v instanceof Long\n        || v instanceof Double || v instanceof Boolean || v instanceof byte[];\n}","tryCatchPattern":null,"preventionTips":["Restrict Configuration values to the six legacy types when using the deprecated writer.","Encode Duration/MemorySize/list values as strings.","Move to the non-deprecated serialization path for new code."],"tags":["configuration","serialization","legacy-api","type-mismatch","flink-core"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}