This is an automated email from the ASF dual-hosted git repository.
mchades pushed a commit to branch branch-0.9
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/branch-0.9 by this push:
new 352a33cebb [#7521] fix(common): Fix precondition message mismatch
(#7534)
352a33cebb is described below
commit 352a33cebb4179b022405fd70baae1b780441552
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Jul 1 23:42:08 2025 +0800
[#7521] fix(common): Fix precondition message mismatch (#7534)
### What changes were proposed in this pull request?
Update the error message in Preconditions.checkState to match the
validation logic.
This change ensures that the error message accurately reflects the
status being checked by the code.
### Why are the changes needed?
Previously, the validation logic allowed values greater than or equal to
-1, but the error message stated that only values greater than -1 were
acceptable. This could mislead users or developers.
Fix: #7521
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
Local verification.
Co-authored-by: fad <[email protected]>
---
common/src/main/java/org/apache/gravitino/dto/rel/DistributionDTO.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git
a/common/src/main/java/org/apache/gravitino/dto/rel/DistributionDTO.java
b/common/src/main/java/org/apache/gravitino/dto/rel/DistributionDTO.java
index 1a1eddef90..3b50042397 100644
--- a/common/src/main/java/org/apache/gravitino/dto/rel/DistributionDTO.java
+++ b/common/src/main/java/org/apache/gravitino/dto/rel/DistributionDTO.java
@@ -163,7 +163,8 @@ public class DistributionDTO implements Distribution {
strategy = strategy == null ? Strategy.HASH : strategy;
Preconditions.checkState(args != null, "expressions cannot be null");
- Preconditions.checkState(number >= 0, "bucketNum must be greater than
0");
+ // Check if the number of buckets is greater than -1, -1 is auto.
+ Preconditions.checkState(number >= -1, "bucketNum must be greater than
or equal -1");
return new DistributionDTO(strategy, number, args);
}
}