AmanMishra1996 opened a new pull request, #11886:
URL: https://github.com/apache/seatunnel/pull/11886
### Purpose of this pull request
Related #11007
Migrate MongoDB Source `fetch.size` validation from the imperative runtime
check in `MongodbReadOptions` to declarative `OptionRule` validation.
Changes:
- Add `Conditions.greaterThan(MongodbSourceOptions.FETCH_SIZE, 0)` to
`MongodbSourceFactory.optionRule()`.
- Remove the now-redundant `checkArgument(fetchSize > 0, ...)` validation
from `MongodbReadOptions`.
- Add factory-level validation tests covering the default, positive, zero,
and negative `fetch.size` cases.
This preserves the existing `fetch.size > 0` contract. The default value
remains unchanged, and no previously valid configuration becomes invalid.
### Does this PR introduce _any_ user-facing change?
Yes, only the validation timing and error reporting change.
Previously, a non-positive `fetch.size` could pass `OptionRule` validation
and fail later when MongoDB read options were constructed by the runtime
validation in `MongodbReadOptions`.
With this change, `fetch.size <= 0` is rejected earlier during standard
configuration validation with `OptionValidationException`.
There is no backward-incompatible configuration change:
- The option name is unchanged.
- The default value is unchanged.
- Positive `fetch.size` values remain valid.
- `fetch.size = 0` and negative values were already invalid before this
change.
### How was this patch tested?
Added focused cases to `MongodbFactoryTest` covering:
- omitted `fetch.size` — passes validation using the existing default
- `fetch.size = 1` — passes validation
- `fetch.size = 2048` — passes validation
- `fetch.size = 0` — rejected with `OptionValidationException`
- `fetch.size = -1` — rejected with `OptionValidationException`
Focused unit test:
```bash
./mvnw \
-pl seatunnel-connectors-v2/connector-mongodb \
-Dtest=MongodbFactoryTest \
-Dsurefire.failIfNoSpecifiedTests=false \
test
--
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]