{"record":{"id":"52d752a51e68c58d","repo":"apache/pulsar","slug":"genericschema-interface-implementation-class-must","errorCode":null,"errorMessage":"GenericSchema interface implementation class must rewrite this method !","messagePattern":"GenericSchema interface implementation class must rewrite this method !","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"pulsar-client-api/src/main/java/org/apache/pulsar/client/api/schema/GenericSchema.java","lineNumber":50,"sourceCode":"public interface GenericSchema<T extends GenericRecord> extends Schema<T> {\n\n    /**\n     * Returns the list of fields.\n     *\n     * @return the list of fields of generic record.\n     */\n    List<Field> getFields();\n\n    /**\n     * Create a builder to build {@link GenericRecord}.\n     *\n     * @return generic record builder\n     */\n    GenericRecordBuilder newRecordBuilder();\n\n\n    static GenericSchema<?> of(SchemaInfo schemaInfo) {\n        throw new RuntimeException(\"GenericSchema interface implementation class must rewrite this method !\");\n    }\n\n    static GenericSchema<?> of(SchemaInfo schemaInfo,\n                            boolean useProvidedSchemaAsReaderSchema) {\n        throw new RuntimeException(\"GenericSchema interface implementation class must rewrite this method !\");\n    }\n\n\n\n}\n","sourceCodeStart":32,"sourceCodeEnd":61,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-api/src/main/java/org/apache/pulsar/client/api/schema/GenericSchema.java#L32-L61","documentation":"GenericSchema.of(SchemaInfo) is a static interface method that intentionally throws RuntimeException: interfaces cannot supply a meaningful construction, so concrete GenericSchema implementations must provide the factory. Invoking GenericSchema.of(...) statically on the interface type always fails; you must call it on or through a concrete implementation such as the AutoConsumeSchema/AvroSchemaImpl-backed generic schemas obtained from the client implementation.","triggerScenarios":"Calling GenericSchema.of(schemaInfo) or GenericSchema.of(schemaInfo, useProvidedSchemaAsReaderSchema) directly — the interface's static body always throws, regardless of arguments.","commonSituations":"IDE auto-import resolving the static of() to the interface instead of a concrete class; generic utility code written against the Schema API assuming a static factory exists on GenericSchema; following outdated examples that predate the concrete factory relocation.","solutions":["Build the generic schema from the client implementation instead, e.g. via Schema.generic(schemaInfo) or the internal generic schema constructors (AvroSchemaImpl / GenericSchemaImpl).","Use AutoConsumeSchema or Schema.AUTO_CONSUME() when you just need to read records without a specific schema class.","If you implement GenericSchema yourself, expose a static of(SchemaInfo) on your concrete class and route callers there."],"exampleFix":"// before\nGenericSchema<?> schema = GenericSchema.of(schemaInfo); // always throws\n// after\nSchema<GenericRecord> schema = Schema.generic(schemaInfo);","handlingStrategy":"fallback","validationCode":"// Never call the interface static directly; use the public factory\nSchema<GenericRecord> schema = Schema.generic(schemaInfo);","typeGuard":null,"tryCatchPattern":"GenericSchema<?> schema;\ntry {\n    schema = GenericSchema.of(schemaInfo);\n} catch (RuntimeException e) {\n    schema = (GenericSchema<?>) Schema.generic(schemaInfo); // concrete implementation\n}","preventionTips":["Treat GenericSchema.of(...) statics as documentation-only stubs; use Schema.generic(schemaInfo) or client-impl constructors.","Check static-import resolution: an import of GenericSchema.of always points at the throwing stub.","For schemaless consumption, prefer Schema.AUTO_CONSUME() over building GenericSchema by hand."],"tags":["generic-schema","interface-static","unsupported-operation"],"backgroundTag":"abstract-method-invoked","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}