apache/flink · error · IllegalArgumentException
Unrecognized type. This method is deprecated and might not…
Error message
Unrecognized type. This method is deprecated and might not work for all supported types.
What it means
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.
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.
Example fix
// before
conf.set("job.duration", Duration.ofSeconds(30)); // later writeToStream -> IllegalArgumentException
// after
conf.set("job.duration", "30 s"); Defensive patterns
Strategy: type-guard
Validate before calling
static boolean legacyWritable(Configuration conf) {
synchronized (conf.confData) {
return conf.confData.values().stream()
.allMatch(v -> v == null || v instanceof String || v instanceof Integer
|| v instanceof Long || v instanceof Double || v instanceof Boolean
|| v instanceof byte[]);
}
} Type guard
boolean isLegacySerializableValue(Object v) {
return v instanceof String || v instanceof Integer || v instanceof Long
|| v instanceof Double || v instanceof Boolean || v instanceof byte[];
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Configuration cannot evaluate value
- Unrecognized type: . This method is deprecated and might…
- A TypeInfoFactory for type
- Cannot find any jar files for plugin in directory
- Cannot register null class or serializer.
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/986e584a73754368.
Report an issue: GitHub.
Appendix: source
Thrown at flink-core/src/main/java/org/apache/flink/configuration/Configuration.java:629
} else if (clazz == Long.class) {
out.write(TYPE_LONG);
out.writeLong((Long) val);
} else if (clazz == Float.class) {
out.write(TYPE_FLOAT);
out.writeFloat((Float) val);
} else if (clazz == Double.class) {
out.write(TYPE_DOUBLE);
out.writeDouble((Double) val);
} else if (clazz == byte[].class) {
out.write(TYPE_BYTES);
byte[] bytes = (byte[]) val;
out.writeInt(bytes.length);
out.write(bytes);
} else if (clazz == Boolean.class) {
out.write(TYPE_BOOLEAN);
out.writeBoolean((Boolean) val);
} else {
throw new IllegalArgumentException(
"Unrecognized type. This method is deprecated and might not work"
+ " for all supported types.");
}
}
}
}
// --------------------------------------------------------------------------------------------
@Override
public int hashCode() {
int hash = 0;
for (String s : this.confData.keySet()) {
hash ^= s.hashCode();
}
return hash;
}
View on GitHub (pinned to 2f3c205e92)