amalsaidov opened a new pull request, #13235:
URL: https://github.com/apache/seatunnel/pull/13235

   Yes, happy to contribute this to Apache SeaTunnel.
   
   ### Purpose of this pull request
   
   Closes #13232. Part of #11007 (migrate connector/API validation to 
declarative `OptionRule`).
   
   `MultiTableSink` checked `multi_table_sink_replica < 1` in its constructor 
and threw an `IllegalArgumentException`. The range was enforced, but the rule 
was not declared in `MultiTableSinkFactory.optionRule()`, so 
`FactoryUtil.createMultiTableSink()` ran `ConfigValidator` against an empty 
rule and the check only fired later, during sink construction.
   
   ### What changed
   
   - `MultiTableSinkFactory.optionRule()` now declares 
`MULTI_TABLE_SINK_REPLICA` with 
`Conditions.greaterThan(MULTI_TABLE_SINK_REPLICA, 0)`. 
`FactoryUtil.createMultiTableSink()` already validates the factory rule before 
constructing the sink, so `0` and negative values are rejected at that point 
with an `OptionValidationException` naming the option.
   - Removed the duplicated `replicaNum < 1` check and its comment from the 
`MultiTableSink` constructor. The option is still read there; the lower bound 
is enforced declaratively upstream.
   - The option stays optional, type `int`, default `1`, valid range `>= 1`. No 
config key, default, or public API changed.
   
   ### How was this patch tested?
   
   Reworked the replica-count tests in `MultiTableSinkWriterTest` to exercise 
the production path:
   
   - `ConfigValidator.of(cfg).validate(optionRule)` rejects `0` and `-1` with 
an `OptionValidationException` that names the option.
   - `FactoryUtil.createMultiTableSink()` rejects `0` and `-1`, wrapping the 
failure in a `FactoryException` whose cause is the `OptionValidationException`, 
confirming validation happens before sink construction.
   - `1`, `4`, and an omitted option (default `1`) still create the sink.
   
   ```
   ./mvnw -pl seatunnel-api -am -DskipTests install
   ./mvnw -pl seatunnel-api -Dtest=MultiTableSinkWriterTest test
   ```
   
   Both pass on JDK 21.
   
   ---
   AI-assisted; directed, reviewed and tested by the author.
   


-- 
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]

Reply via email to