Copilot commented on code in PR #37250:
URL: https://github.com/apache/shardingsphere/pull/37250#discussion_r2577912108


##########
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithm.java:
##########
@@ -114,7 +114,7 @@ private boolean containsAllTargets(final 
RangeShardingValue<Comparable<?>> shard
             return true;
         }
         return 
getBigInteger(shardingValue.getValueRange().upperEndpoint()).subtract(getBigInteger(shardingValue.getValueRange().lowerEndpoint()))
-                .compareTo(BigInteger.valueOf(shardingCount - 1)) >= 0;
+                .compareTo(BigInteger.valueOf(shardingCount - 1L)) >= 0;

Review Comment:
   The change from `shardingCount - 1` to `shardingCount - 1L` may not address 
the underlying issue. If `shardingCount` is an int, subtracting 1 still 
produces an int before the long conversion. If the intention is to prevent 
integer overflow, the operation should be `(long) shardingCount - 1L` or 
`shardingCount` should be cast to long before the subtraction.
   ```suggestion
                   .compareTo(BigInteger.valueOf((long) shardingCount - 1L)) >= 
0;
   ```



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