{"record":{"id":"69f21df7e73c481f","repo":"apache/flink","slug":"class-is-not-a-typeinfofactory-69f21d","errorCode":null,"errorMessage":"Class is not a TypeInfoFactory.","messagePattern":"Class is not a TypeInfoFactory\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java","lineNumber":163,"sourceCode":"            registeredTypeInfoFactories = new HashMap<>();\n\n    /**\n     * Registers a type information factory globally for a certain type. Every following type\n     * extraction operation will use the provided factory for this type. The factory will have the\n     * highest precedence for this type. In a hierarchy of types the registered factory has higher\n     * precedence than annotations at the same level but lower precedence than factories defined\n     * down the hierarchy.\n     *\n     * @param t type for which a new factory is registered\n     * @param factory type information factory that will produce {@link TypeInformation}\n     */\n    @Internal\n    public static void registerFactory(Type t, Class<? extends TypeInfoFactory<?>> factory) {\n        Preconditions.checkNotNull(t, \"Type parameter must not be null.\");\n        Preconditions.checkNotNull(factory, \"Factory parameter must not be null.\");\n\n        if (!TypeInfoFactory.class.isAssignableFrom(factory)) {\n            throw new IllegalArgumentException(\"Class is not a TypeInfoFactory.\");\n        }\n        if (registeredTypeInfoFactories.containsKey(t)) {\n            throw new InvalidTypesException(\n                    \"A TypeInfoFactory for type '\" + t + \"' is already registered.\");\n        }\n        registeredTypeInfoFactories.put(t, factory);\n    }\n\n    // --------------------------------------------------------------------------------------------\n    //  Function specific methods\n    // --------------------------------------------------------------------------------------------\n\n    @PublicEvolving\n    public static <IN, OUT> TypeInformation<OUT> getMapReturnTypes(\n            MapFunction<IN, OUT> mapInterface, TypeInformation<IN> inType) {\n        return getMapReturnTypes(mapInterface, inType, null, false);\n    }\n","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java#L145-L181","documentation":"Thrown by TypeExtractor.registerFactory when the provided factory class does not implement TypeInfoFactory. The method checks TypeInfoFactory.class.isAssignableFrom(factory) and rejects any class that is not a subtype. This is a programming error: the caller passed a class that is not a valid TypeInfoFactory implementation.","triggerScenarios":"Calling TypeExtractor.registerFactory(type, SomeClass.class) where SomeClass does not extend TypeInfoFactory. Passing a raw Class without the generic bound. Accidentally passing a TypeInformation subclass instead of a TypeInfoFactory subclass.","commonSituations":"Developer confuses TypeInfoFactory (produces TypeInformation) with TypeInformation itself. Custom type factory implementation that forgot to extend TypeInfoFactory. Copy-paste error registering the wrong class.","solutions":["Ensure the factory class extends TypeInfoFactory<T> and implements createTypeInfo(Type, Map).","Check the class hierarchy: the registered class must be a direct or indirect subtype of TypeInfoFactory.","Use the correct class reference in the registerFactory call."],"exampleFix":"// before\nTypeExtractor.registerFactory(MyType.class, MyTypeInfo.class); // MyTypeInfo extends TypeInformation, not TypeInfoFactory\n// after\npublic class MyTypeInfoFactory extends TypeInfoFactory<MyType> {\n    public TypeInformation<MyType> createTypeInfo(Type t, Map<String, TypeInformation<?>> m) {\n        return new MyTypeInfo();\n    }\n}\nTypeExtractor.registerFactory(MyType.class, MyTypeInfoFactory.class);","handlingStrategy":"type-guard","validationCode":"if (!TypeInfoFactory.class.isAssignableFrom(factory)) {\n    throw new IllegalArgumentException(\n        factory + \" must extend TypeInfoFactory\");\n}\nTypeExtractor.registerFactory(type, factory);","typeGuard":"static boolean isValidFactory(Class<?> factory) {\n    return TypeInfoFactory.class.isAssignableFrom(factory);\n}","tryCatchPattern":null,"preventionTips":["Always verify the class extends TypeInfoFactory before registering.","Use @SuppressWarnings only after confirming the class hierarchy is correct.","Follow the TypeInfoFactory contract: implement createTypeInfo(Type, Map)."],"tags":["type-extraction","typeinfo-factory","registration","programming-error"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}