[
https://issues.apache.org/jira/browse/FLINK-39916?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
XiaodongHuan updated FLINK-39916:
---------------------------------
Description:
*Description*
In `MySqlDataSourceFactory`, the exception uses `{}` as a placeholder inside
`String.format(...)`.
However, `String.format(...)` only supports Java formatter placeholders such as
`%s`. The `{}` placeholder will not be replaced.
*Current Code*
```java
throw new IllegalArgumentException(
String.format(
"Only \"snapshot\" of MySQLDataSource StartupOption is
supported in BATCH pipeline, but actual MySQLDataSource StartupOption is {}.",
startupOptions.startupMode));
```
h2. Expected Behavior
The actual startup mode should be included in the exception.
h2. Suggested Fix
Replace {{{}}} with \{{{}%s{}}}.
h2. Additional Cleanup
The same file also contains an unused constant:
private static final String DOT_PLACEHOLDER = "{_}$dot_placeholder${_}";
This constant is not referenced anywhere in {{MySqlDataSourceFactory}} and can
be safely removed as part of the same small cleanup.
h2. File
{{flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-mysql/src/main/java/org/apache/flink/cdc/connectors/mysql/factory/MySqlDataSourceFactory.java}}
was:
## Description
In `MySqlDataSourceFactory`, the exception uses `{}` as a placeholder inside
`String.format(...)`.
However, `String.format(...)` only supports Java formatter placeholders such as
`%s`. The `{}` placeholder will not be replaced.
## Current Code
```java
throw new IllegalArgumentException(
String.format(
"Only \"snapshot\" of MySQLDataSource StartupOption is
supported in BATCH pipeline, but actual MySQLDataSource StartupOption is {}.",
startupOptions.startupMode));
h2. Expected Behavior
The actual startup mode should be included in the exception.
h2. Suggested Fix
Replace {{{}}} with {{{}%s{}}}.
h2. Additional Cleanup
The same file also contains an unused constant:
private static final String DOT_PLACEHOLDER = "_$dot_placeholder$_";
This constant is not referenced anywhere in {{MySqlDataSourceFactory}} and can
be safely removed as part of the same small cleanup.
h2. File
{{flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-mysql/src/main/java/org/apache/flink/cdc/connectors/mysql/factory/MySqlDataSourceFactory.java}}
> Incorrect placeholder used in MySqlDataSourceFactory exception message
> ----------------------------------------------------------------------
>
> Key: FLINK-39916
> URL: https://issues.apache.org/jira/browse/FLINK-39916
> Project: Flink
> Issue Type: Bug
> Components: Flink CDC
> Affects Versions: cdc-3.5.0
> Reporter: XiaodongHuan
> Priority: Minor
> Labels: pull-request-available
>
> *Description*
> In `MySqlDataSourceFactory`, the exception uses `{}` as a placeholder inside
> `String.format(...)`.
> However, `String.format(...)` only supports Java formatter placeholders such
> as `%s`. The `{}` placeholder will not be replaced.
> *Current Code*
> ```java
> throw new IllegalArgumentException(
> String.format(
> "Only \"snapshot\" of MySQLDataSource StartupOption is
> supported in BATCH pipeline, but actual MySQLDataSource StartupOption is {}.",
> startupOptions.startupMode));
> ```
> h2. Expected Behavior
> The actual startup mode should be included in the exception.
> h2. Suggested Fix
> Replace {{{}}} with \{{{}%s{}}}.
> h2. Additional Cleanup
> The same file also contains an unused constant:
> private static final String DOT_PLACEHOLDER = "{_}$dot_placeholder${_}";
> This constant is not referenced anywhere in {{MySqlDataSourceFactory}} and
> can be safely removed as part of the same small cleanup.
> h2. File
> {{flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-mysql/src/main/java/org/apache/flink/cdc/connectors/mysql/factory/MySqlDataSourceFactory.java}}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)