You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "dangzitou (via GitHub)" <gi...@apache.org> on 2026/06/03 11:52:51 UTC
[PR] [hotfix] Use explicit UTF-8 charset in coerceToBytes and guard Optional.get() in Kafka serializers [flink-cdc]
dangzitou opened a new pull request, #4427:
URL: https://github.com/apache/flink-cdc/pull/4427
## What this PR does
This PR fixes two minor but important issues:
### 1. Platform-default charset in `SchemaMergingUtils.coerceToBytes()`
**File:** `flink-cdc-common/.../SchemaMergingUtils.java:617`
`originalField.toString().getBytes()` uses the platform-default charset, which can vary across JVM configurations and operating systems. This causes inconsistent behavior when converting fields to bytes during schema evolution.
**Fix:** Use `StandardCharsets.UTF_8` explicitly.
### 2. Unchecked `Optional.get()` in Kafka serialization schemas
**Files:**
- `CsvSerializationSchema.java:109`
- `JsonSerializationSchema.java:132`
Both files call `schema.getColumn(...).get()` without checking if the Optional is present. If a primary key column is missing from the schema (e.g., after schema evolution), this throws a bare `NoSuchElementException` with no context.
**Fix:** Replace with `orElseThrow()` that includes the missing column name in the error message.
## Testing
These are straightforward defensive improvements:
- The charset fix ensures consistent UTF-8 encoding regardless of JVM locale
- The Optional guard improves error diagnostics without changing happy-path behavior
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [hotfix] Use explicit UTF-8 charset in coerceToBytes and guard Optional.get() in Kafka serializers [flink-cdc]
Posted by "dangzitou (via GitHub)" <gi...@apache.org>.
dangzitou closed pull request #4427: [hotfix] Use explicit UTF-8 charset in coerceToBytes and guard Optional.get() in Kafka serializers
URL: https://github.com/apache/flink-cdc/pull/4427
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [hotfix] Use explicit UTF-8 charset in coerceToBytes and guard Optional.get() in Kafka serializers [flink-cdc]
Posted by "yuxiqian (via GitHub)" <gi...@apache.org>.
yuxiqian commented on PR #4427:
URL: https://github.com/apache/flink-cdc/pull/4427#issuecomment-4618231569
Hi @dangzitou, thank you for your contribution!
It looks like this PR addresses three independent issues (the UTF-8 fix, the Doris change, and the Kafka change). Could you split them into separate JIRA tickets with one PR each? That makes review easier and keeps the git history clean.
Thanks again!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org