{"record":{"id":"528447e5afa822cf","repo":"alibaba/canal","slug":"extension-type-null-528447","errorCode":null,"errorMessage":"Extension type == null","messagePattern":"Extension type == null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"connector/core/src/main/java/com/alibaba/otter/canal/connector/core/spi/ExtensionLoader.java","lineNumber":72,"sourceCode":"    private final Holder<Map<String, Class<?>>>                      cachedClasses              = new Holder<>();\n\n    private final ConcurrentMap<String, Holder<Object>>              cachedInstances            = new ConcurrentHashMap<>();\n\n    private String                                                   cachedDefaultName;\n\n    private ConcurrentHashMap<String, IllegalStateException>         exceptions                 = new ConcurrentHashMap<>();\n\n    private static <T> boolean withExtensionAnnotation(Class<T> type) {\n        return type.isAnnotationPresent(SPI.class);\n    }\n\n    public static <T> ExtensionLoader<T> getExtensionLoader(Class<T> type) {\n        return getExtensionLoader(type, DEFAULT_CLASSLOADER_POLICY);\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public static <T> ExtensionLoader<T> getExtensionLoader(Class<T> type, String classLoaderPolicy) {\n        if (type == null) throw new IllegalArgumentException(\"Extension type == null\");\n        if (!type.isInterface()) {\n            throw new IllegalArgumentException(\"Extension type(\" + type + \") is not interface!\");\n        }\n        if (!withExtensionAnnotation(type)) {\n            throw new IllegalArgumentException(\"Extension type(\" + type + \") is not extension, because WITHOUT @\"\n                                               + SPI.class.getSimpleName() + \" Annotation!\");\n        }\n\n        ExtensionLoader<T> loader = (ExtensionLoader<T>) EXTENSION_LOADERS.get(type);\n        if (loader == null) {\n            EXTENSION_LOADERS.putIfAbsent(type, new ExtensionLoader<T>(type, classLoaderPolicy));\n            loader = (ExtensionLoader<T>) EXTENSION_LOADERS.get(type);\n        }\n        return loader;\n    }\n\n    public ExtensionLoader(Class<?> type){\n        this.type = type;","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/connector/core/src/main/java/com/alibaba/otter/canal/connector/core/spi/ExtensionLoader.java#L54-L90","documentation":"Thrown by ExtensionLoader.getExtensionLoader(type, policy) when the supplied Class<T> type is null. This is a programming-error guard at the very start of SPI loader acquisition; type must be a non-null @SPI-annotated interface before any extension lookup can occur.","triggerScenarios":"Passing a null class reference to getExtensionLoader — typically because a constant/field that should hold the interface resolved to null (e.g. dead code path, class stripping, or a generic helper that forwards a possibly-null type).","commonSituations":"Refactoring that left a null where an interface type was expected; DI/proxy code passing a null type through reflection; calling getExtensionLoader from a code path where the type was never initialized.","solutions":["Ensure a non-null @SPI interface Class is passed, e.g. ExtensionLoader.getExtensionLoader(CanalMQProducer.class).","Fix the upstream null (initialize the type field / pass the concrete interface constant)."],"exampleFix":"// before\nClass<?> type = resolveOrNull();\nExtensionLoader.getExtensionLoader(type);\n// after\nExtensionLoader.getExtensionLoader(CanalMQProducer.class);","handlingStrategy":"validation","validationCode":"// Ensure type is non-null before acquiring a loader\nif (type == null) {\n    throw new IllegalArgumentException(\"extension type must not be null at \" + caller);\n}\nExtensionLoader.getExtensionLoader(type);","typeGuard":null,"tryCatchPattern":"try {\n    ExtensionLoader.getExtensionLoader(type);\n} catch (IllegalArgumentException e) {\n    // programming error: fix the caller passing null\n    throw new IllegalStateException(\"BUG: null extension type\", e);\n}","preventionTips":["Never forward a possibly-null type into getExtensionLoader.","Pass the concrete interface constant directly."],"tags":["spi","programming-error","extension-loader"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}