apache/flink · error · UnsupportedOperationException
Generic types have been disabled in the ExecutionConfig and
Error message
Generic types have been disabled in the ExecutionConfig and type {} is treated as a generic type. What it means
Thrown by GenericTypeInfo.createSerializer() when ExecutionConfig has disabled generic types (hasGenericTypesDisabled() == true) but the type in question is a generic type (i.e. only Kryo could serialize it). Disabling generic types is an explicit opt-in safety feature that forces users to provide proper POJO/Avro type info; hitting this error means a type fell through to the generic/Kryo fallback that the user forbade.
Source
Thrown at flink-core/src/main/java/org/apache/flink/api/java/typeutils/GenericTypeInfo.java:86
}
@Override
@PublicEvolving
public Class<T> getTypeClass() {
return typeClass;
}
@Override
@PublicEvolving
public boolean isKeyType() {
return Comparable.class.isAssignableFrom(typeClass);
}
@Override
@PublicEvolving
public TypeSerializer<T> createSerializer(SerializerConfig config) {
if (config.hasGenericTypesDisabled()) {
throw new UnsupportedOperationException(
"Generic types have been disabled in the ExecutionConfig and type "
+ this.typeClass.getName()
+ " is treated as a generic type.");
}
return new KryoSerializer<T>(this.typeClass, config);
}
@SuppressWarnings("unchecked")
@Override
@PublicEvolving
public TypeComparator<T> createComparator(
boolean sortOrderAscending, ExecutionConfig executionConfig) {
if (isKeyType()) {
@SuppressWarnings("rawtypes")
GenericTypeComparator comparator =
new GenericTypeComparator(
sortOrderAscending,View on GitHub (pinned to 2f3c205e92)
Solutions
- Make the offending class a proper POJO (public, no-arg constructor, public getters/setters) so Flink uses PojoTypeInfo instead of GenericTypeInfo.
- Register an explicit TypeInformation / TypeSerializer for the class via .registerTypeWithKryoSerializer or a TypeInfoFactory.
- If Kryo is acceptable, re-enable generic types: executionConfig.enableGenericTypes().
- Switch to a Tuple, Row, or Avro type that Flink understands natively.
Example fix
// before
env.getConfig().disableGenericTypes();
env.fromElements(new MyType()); // MyType not a valid POJO -> GenericTypeInfo -> throw
// after: make MyType a proper POJO
public class MyType {
public MyType() {}
private int v; public int getV(){return v;} public void setV(int v){this.v=v;}
} Defensive patterns
Strategy: validation
Validate before calling
// Validate type is a POJO before disabling generics
if (TypeInformation.of(MyType.class) instanceof GenericTypeInfo) {
throw new IllegalStateException("MyType is generic; make it a POJO before disableGenericTypes()");
} Type guard
static boolean isPojo(Class<?> c) {
return TypeInformation.of(c) instanceof org.apache.flink.api.java.typeutils.PojoTypeInfo;
} Prevention
- Ensure all domain types are valid POJOs before calling disableGenericTypes().
- Add TypeInfoFactory annotations to enforce type safety.
- Run a local job to surface degradation to generic before production.
When it happens
Trigger: Calling executionConfig.disableGenericTypes() (or the equivalent) and then having TypeExtractor produce a GenericTypeInfo for some type in the job, which triggers createSerializer().
Common situations: A team enables 'no generics' to enforce type safety, then introduces a type Flink cannot treat as a POJO (missing getter/setter, non-public class, nested generics) so it degrades to generic and the serializer creation fails at runtime.
Related errors
- Cannot create Comparator for {typeClass.getCanonicalName()}.
- The given class is no subclass of {Writable.class.getName()}
- Parallelism must be at least one, or ExecutionConfig.PARALLE
- Execution config has not been set properly for this plan
- Failed to serialize value '{value}'
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/3dd3530f77ea5def.
Report an issue: GitHub.