sharpca opened a new pull request, #13081:
URL: https://github.com/apache/seatunnel/pull/13081
### Purpose of this pull request
Fixes #13080.
The starters convert enum-valued command line arguments with
`String#toUpperCase()` / `String#toLowerCase()` without a locale before
matching them against the enum constants. Under a Turkish or Azerbaijani
default locale those calls produce dotted capital I characters (`client` ->
`CLİENT`, `sink` -> `SİNK`), so the values no longer match any enum constant.
As a result, with `-Duser.language=tr -Duser.country=TR`:
- the Spark starter rejects `--deploy-mode client` with `No enum constant
...DeployMode.CLİENT`;
- the Flink starter rejects `--deploy-mode run-application` and `--target
yarn-session` / `kubernetes-application`;
- `seatunnel-connector.sh -pt sink` and the metadata export `-pt sink`
report that the plugin type is not supported, although `sink` was passed;
- `DeployMode.from(String)` returns an empty `Optional` for `CLIENT` and
throws a `NullPointerException` for `null`.
This change converts the argument with `Locale.ROOT` in all of those places
and makes `DeployMode.from` locale independent and null safe.
### Does this PR introduce _any_ user-facing change?
Yes, but only for JVMs whose default locale is Turkish or Azerbaijani: the
CLI arguments above are now parsed the same way as on any other locale. Nothing
changes for the default locale or for valid/invalid argument handling.
### How was this patch tested?
Unit tests are added:
- `DeployModeTest` covers `DeployMode.from` for valid values, an unknown
value, `null`, and `tr-TR`.
- `FlinkCommandArgsConverterTest` covers the Flink deploy mode and master
target converters, including `run-application`, `yarn-session` and
`kubernetes-application` under `tr-TR`.
- `SparkCommandArgsConverterTest` covers the Spark deploy mode converter
under `tr-TR`.
- `ConnectorCheckCommandArgsTest#testPluginTypeArgumentIsLocaleIndependent`
parses `-pt sink` under `tr-TR` and also checks the metadata export converter.
```shell
mvn -pl seatunnel-common test -Dtest=DeployModeTest
mvn -pl :seatunnel-flink-starter-common,:seatunnel-spark-starter-common test
\
-Dtest=FlinkCommandArgsConverterTest,SparkCommandArgsConverterTest
mvn -pl :seatunnel-starter test -Dtest=ConnectorCheckCommandArgsTest
```
Every new test was also run against the unpatched sources to confirm that it
fails under `tr-TR` (`expected: <Optional[CLIENT]> but was: <Optional.empty>`,
`No enum constant ...DeployMode.CLİENT`).
### Check list
* [ ] If any new Jar binary package adding in your PR, please add License
Notice according
[New License
Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/developer/new-license.md)
* [ ] If necessary, please update the documentation to describe the new
feature. https://github.com/apache/seatunnel/tree/dev/docs
* [ ] If necessary, please update `incompatible-changes.md` to describe the
incompatibility caused by this PR.
* [ ] If you are contributing the connector code, please check that the
following files are updated:
1. Update
[plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties)
and add new connector information in it
2. Update the pom file of
[seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
3. Add ci label in
[label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml)
4. Add e2e testcase in
[seatunnel-e2e](https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/)
5. Update connector
[plugin_config](https://github.com/apache/seatunnel/blob/dev/config/plugin_config)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]