flink-cdc
flink-cdc copied to clipboard
[hotfix] Use explicit UTF-8 charset in getBytes() calls across connectors
What this PR does
Replaces platform-default String.getBytes() with String.getBytes(StandardCharsets.UTF_8) across multiple modules to ensure consistent encoding behavior regardless of JVM locale or OS configuration.
Affected files
SchemaMergingUtils.java+ test — core schema coercionDebeziumJsonSerializationSchema.java— Kafka Debezium JSON default value handlingRowDataTiKVEventDeserializationSchemaBase.java— TiDB source connectorBinaryTypeReturningClass.java/VarBinaryTypeReturningClass.java— UDF examples
Why
String.getBytes() without an explicit charset uses the JVM's default charset, which varies across environments (e.g., US-ASCII on some minimal Docker images, GBK on Chinese Windows). This causes silent data corruption when non-ASCII characters are involved. Using UTF-8 explicitly makes the behavior deterministic.
Testing
These are straightforward defensive improvements — the fix ensures consistent UTF-8 encoding regardless of JVM locale.
Split from #4427 as requested by @yuxiqian.