{"record":{"id":"fa15cc6556aecb2d","repo":"alibaba/canal","slug":"unsupported-connection-type-connection-getcla","errorCode":null,"errorMessage":"Unsupported connection type :  + connection.getClass().getSimpleName()","messagePattern":"Unsupported connection type :  \\+ connection\\.getClass\\(\\)\\.getSimpleName\\(\\)","errorType":"exception","errorClass":"CanalParseException","httpStatus":null,"severity":"error","filePath":"parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlEventParser.java","lineNumber":80,"sourceCode":"    private TableMetaCache       tableMetaCache;                               // 对应meta\n    private int                  fallbackIntervalInSeconds         = 60;       // 切换回退时间\n    private BinlogFormat[]       supportBinlogFormats;                         // 支持的binlogFormat,如果设置会执行强校验\n    private BinlogImage[]        supportBinlogImages;                          // 支持的binlogImage,如果设置会执行强校验\n\n    // update by yishun.chen,特殊异常处理参数\n    private int                  dumpErrorCount                    = 0;        // binlogDump失败异常计数\n    private int                  dumpErrorCountThreshold           = 2;        // binlogDump失败异常计数阀值\n    private boolean              rdsOssMode                        = false;\n    private boolean              autoResetLatestPosMode            = false;    // binlog被删除之后，自动按最新的数据订阅\n    private boolean              multiStreamEnable;                            // support for polardbx binlog-x\n\n    protected ErosaConnection buildErosaConnection() {\n        return buildMysqlConnection(this.runningInfo);\n    }\n\n    protected void preDump(ErosaConnection connection) {\n        if (!(connection instanceof MysqlConnection)) {\n            throw new CanalParseException(\"Unsupported connection type : \" + connection.getClass().getSimpleName());\n        }\n\n        if (binlogParser != null && binlogParser instanceof LogEventConvert) {\n            metaConnection = (MysqlConnection) connection.fork();\n            try {\n                metaConnection.connect();\n            } catch (IOException e) {\n                throw new CanalParseException(e);\n            }\n\n            if (supportBinlogFormats != null && supportBinlogFormats.length > 0) {\n                BinlogFormat format = ((MysqlConnection) metaConnection).getBinlogFormat();\n                boolean found = false;\n                for (BinlogFormat supportFormat : supportBinlogFormats) {\n                    if (supportFormat != null && format == supportFormat) {\n                        found = true;\n                        break;\n                    }","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlEventParser.java#L62-L98","documentation":"MysqlEventParser.preDump(ErosaConnection) only handles MysqlConnection instances. If the supplied ErosaConnection is any other concrete type, it throws CanalParseException naming the actual class. This is a defensive type check at the boundary where canal's abstract ErosaConnection (designed to also support Oracle) meets the MySQL-specific implementation.","triggerScenarios":"A subclass of MysqlEventParser or a custom AbstractEventParser wiring returns a non-MysqlConnection ErosaConnection from buildErosaConnection(), and preDump receives it.","commonSituations":"Extending the parser for a different DB backend but routing it through MysqlEventParser; misconfigured parser class in instance properties; a custom ErosaConnection wrapper that does not extend MysqlConnection.","solutions":["Ensure buildErosaConnection() returns a MysqlConnection (the default buildMysqlConnection does).","If you wrote a custom connection type, use the matching AbstractEventParser subclass, not MysqlEventParser.","Check canal.instance.parser.type / the parser bean class is MysqlEventParser for MySQL sources."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"private static boolean isMysqlConnection(ErosaConnection c) {\n    return c != null && c instanceof MysqlConnection;\n}","tryCatchPattern":null,"preventionTips":["Ensure buildErosaConnection() returns a MysqlConnection.","Use the correct parser subclass for non-MySQL backends.","Do not wrap MysqlConnection in a non-MysqlConnection adapter."],"tags":["type-guard","mysql","connection","canal-parse"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}