{"record":{"id":"e7817808af74ddb8","repo":"apache/seatunnel","slug":"could-not-read-mysql-time-value-as-utf-8","errorCode":null,"errorMessage":"Could not read MySQL TIME value as UTF-8","messagePattern":"Could not read MySQL TIME value as UTF-8","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/source/reader/fetch/scan/MySqlSnapshotSplitReadTask.java","lineNumber":326,"sourceCode":"        }\n    }\n\n    /**\n     * As MySQL connector/J implementation is broken for MySQL type \"TIME\" we have to use a\n     * binary-ish workaround. https://issues.jboss.org/browse/DBZ-342\n     */\n    private Object readTimeField(ResultSet rs, int fieldNo) throws SQLException {\n        Blob b = rs.getBlob(fieldNo);\n        if (b == null) {\n            return null; // Don't continue parsing time field if it is null\n        }\n\n        try {\n            return MySqlValueConverters.stringToDuration(\n                    new String(b.getBytes(1, (int) (b.length())), \"UTF-8\"));\n        } catch (UnsupportedEncodingException e) {\n            LOG.error(\"Could not read MySQL TIME value as UTF-8\");\n            throw new RuntimeException(e);\n        }\n    }\n\n    /**\n     * In non-string mode the date field can contain zero in any of the date part which we need to\n     * handle as all-zero.\n     */\n    private Object readDateField(ResultSet rs, int fieldNo, Column column, Table table)\n            throws SQLException {\n        Blob b = rs.getBlob(fieldNo);\n        if (b == null) {\n            return null; // Don't continue parsing date field if it is null\n        }\n\n        try {\n            return MySqlValueConverters.stringToLocalDate(\n                    new String(b.getBytes(1, (int) (b.length())), \"UTF-8\"), column, table);\n        } catch (UnsupportedEncodingException e) {","sourceCodeStart":308,"sourceCodeEnd":344,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/source/reader/fetch/scan/MySqlSnapshotSplitReadTask.java#L308-L344","documentation":"readTimeField decodes a MySQL TIME column read as a byte blob, converting it to a UTF-8 string for MySqlValueConverters.stringToDuration. If the JVM does not support the 'UTF-8' encoding name (essentially never in practice), UnsupportedEncodingException is logged and rethrown as RuntimeException.","triggerScenarios":"Calling readField on a TIME column whose value is fetched as bytes, and new String(..., \"UTF-8\") throws UnsupportedEncodingException.","commonSituations":"Practically impossible on standard JVMs (UTF-8 is mandated); only seen with a broken/non-standard JRE or unusual CharsetProvider configuration.","solutions":["Use a standard JVM (JDK 8+) where UTF-8 is always supported","Replace the literal with StandardCharsets.UTF_8 to eliminate the checked exception path"],"exampleFix":"// before\nreturn MySqlValueConverters.stringToDuration(new String(b.getBytes(1, (int) (b.length())), \"UTF-8\"));\n// after\nreturn MySqlValueConverters.stringToDuration(new String(b.getBytes(1, (int) (b.length())), java.nio.charset.StandardCharsets.UTF_8));","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run SeaTunnel on a standard JDK 8+ JVM","Library-side: use StandardCharsets.UTF_8 to remove the path"],"tags":["mysql","cdc","encoding","utf-8"],"backgroundTag":"unsupported-platform","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}