Dev-next-gen opened a new pull request, #12269:
URL: https://github.com/apache/seatunnel/pull/12269
### Purpose of this pull request
While going through the recent locale fixes (#11894 for `JobStatus`, #11994
for the rename transforms) I looked for the same `valueOf(x.toUpperCase())`
pattern elsewhere and found one in `AbstractPluginDiscovery.findPluginJarPath`:
```java
final String pluginType = pluginIdentifier.getPluginType().toLowerCase();
...
PluginType type = PluginType.valueOf(pluginType.toUpperCase());
```
The plugin type comes in as `"sink"`, `"source"` or `"transform"`. When the
JVM default locale is Turkish (or Azerbaijani), `"sink".toUpperCase()` returns
`"SİNK"` with a dotted capital I, so the lookup throws:
```
java.lang.IllegalArgumentException: No enum constant
org.apache.seatunnel.common.constants.PluginType.SİNK
```
This line runs as soon as a matching jar is found under `connectors/`, so on
such a JVM every sink that is resolved from the connectors directory fails to
load. Sources and transforms are not affected because neither word contains an
`i`.
The fix passes `Locale.ROOT`, like the earlier locale fixes did. I left the
`toLowerCase()` calls on the identifier alone: as far as I can tell from the
code, their results only feed `equalsIgnoreCase`, `startsWithIgnoreCase` and
`contains("cdc")`, which do not break the lookup, so I kept the diff to the
line that actually throws.
### Does this PR introduce _any_ user-facing change?
Only for JVMs running with a Turkish or Azerbaijani default locale, where
sink plugin jars are now discovered instead of failing with the exception
above. No public signature changes: the edited line is inside the private
`findPluginJarPath`, and for the three inputs it can receive (`source`, `sink`,
`transform`) `toUpperCase(Locale.ROOT)` returns the same string as
`toUpperCase()` under every other default locale, so behaviour elsewhere is
unchanged.
### How was this patch tested?
I added `getSinkPluginJarPathsUnderTurkishLocale` to
`SeaTunnelSourcePluginDiscoveryTest`. It reuses the existing `duplicate`
fixture, sets the default locale to `tr-TR`, resolves the `Clickhouse` sink jar
and restores the locale afterwards (guarded with
`@ResourceLock("default-locale")`, as in `JobStatusTest`).
Without the change in `AbstractPluginDiscovery` the new test fails:
```
[ERROR] getSinkPluginJarPathsUnderTurkishLocale Time elapsed: 0.013 s <<<
ERROR!
java.lang.IllegalArgumentException: No enum constant
org.apache.seatunnel.common.constants.PluginType.SİNK
[ERROR] Tests run: 6, Failures: 0, Errors: 1, Skipped: 0
```
With the change:
```
./mvnw test -pl seatunnel-plugin-discovery
[INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0
[INFO] BUILD SUCCESS
```
The spotless check runs as part of that build and passes. I ran it locally
on JDK 17.
### 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)
AI tools used
--
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]