You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "thswlsqls (via GitHub)" <gi...@apache.org> on 2026/08/06 23:09:32 UTC
[PR] Allow position 0 for from-x and to-y in mask algorithms [shardingsphere]
thswlsqls opened a new pull request, #39364:
URL: https://github.com/apache/shardingsphere/pull/39364
Fixes #39362.
Changes proposed in this pull request:
- `MASK_FROM_X_TO_Y` and `KEEP_FROM_X_TO_Y` reject `from-x: 0` / `to-y: 0` with `AlgorithmInitializationException`, although `mask.en.md` and `mask.cn.md` both document them as `start position (from 0)` / `end position (from 0)`.
- The runtime is already 0-based: `MaskFromXToYMaskAlgorithm.mask()` uses `fromX` directly as a char array index, so position 0 works once initialization accepts it.
- Add `MaskAlgorithmPropertiesChecker.checkNonNegativeInteger()` and switch the four position-typed call sites (`from-x`, `to-y` in both algorithms) to it.
- Keep `checkPositiveInteger()` unchanged: `first-n` / `last-m` in `KeepFirstNLastMMaskAlgorithm` and `MaskFirstNLastMMaskAlgorithm` are counts, not positions, so `> 0` stays correct for them.
- Negative values are still rejected; the existing `negative_from_X` / `negative_to_Y` init cases still pass.
- Add checker unit tests for zero, positive, negative, missing key and non-integer input, plus `from-x=0` execute cases to both algorithm tests.
- No documentation change: the docs already describe the intended contract, the code did not honour it.
- Verified with `./mvnw install -pl features/mask/core -am` plus repository-wide spotless, checkstyle and apache-rat: 159 tests pass.
---
Before committing this PR, I'm sure that I have checked the following options:
- [x] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
- [x] I have self-reviewed the commit code.
- [ ] I have (or in comment I request) added corresponding labels for the pull request.
- [ ] I have passed maven check locally : `./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
- [ ] I have made corresponding changes to the documentation.
- [x] I have added corresponding unit tests for my changes.
- [x] I have updated the Release Notes of the current development version. For more details, see [Update Release Note](https://shardingsphere.apache.org/community/en/involved/contribute/contributor/)
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Allow position 0 for from-x and to-y in mask algorithms [shardingsphere]
Posted by "thswlsqls (via GitHub)" <gi...@apache.org>.
thswlsqls commented on PR #39364:
URL: https://github.com/apache/shardingsphere/pull/39364#issuecomment-5340427512
@terrymanu Thanks for the review and for the pointer to #39389 — closing makes sense, the two changes are equivalent. One thing carried over: the `to-y=0` public-path gap you flagged here still applies on master, where both algorithm tests use `from-x=0, to-y=2`, so reverting `createToY` to `checkPositiveInteger` would stay green. Happy to send a small follow-up adding the `to-y=0` cases and the release note if that's useful.
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Allow position 0 for from-x and to-y in mask algorithms [shardingsphere]
Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu closed pull request #39364: Allow position 0 for from-x and to-y in mask algorithms
URL: https://github.com/apache/shardingsphere/pull/39364
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Allow position 0 for from-x and to-y in mask algorithms [shardingsphere]
Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu commented on PR #39364:
URL: https://github.com/apache/shardingsphere/pull/39364#issuecomment-5327398689
Hi @thswlsqls, thanks for your contribution and the detailed analysis of this issue.
Unfortunately, this change has been superseded: #39389, which addresses the same issue (#39362), was already merged into `master` on Aug 18 (merge commit `efd97c0`). The two PRs are semantically identical — both add a non-negative integer check to `MaskAlgorithmPropertiesChecker` and switch the `from-x` / `to-y` call sites in `MASK_FROM_X_TO_Y` and `KEEP_FROM_X_TO_Y` to it, with equivalent test coverage.
Since the underlying issue is now resolved, I'm closing this PR to avoid duplicate changes. The only delta not covered by #39389 is the release note entry, which we can add separately referencing #39389 if needed.
Thanks again for reporting and fixing this — feel free to pick up another issue anytime!
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org