You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by wu...@apache.org on 2022/12/06 14:56:58 UTC
[shardingsphere-elasticjob] 01/01: Revert "Bug: Bad attempt to compute absolute value of signed 32-bit hashcode (#2151)"
This is an automated email from the ASF dual-hosted git repository.
wuweijie pushed a commit to branch revert-2151-master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob.git
commit 487eda4ec5d16152c85c5c91848d1785402025ce
Author: 吴伟杰 <wu...@apache.org>
AuthorDate: Tue Dec 6 22:56:52 2022 +0800
Revert "Bug: Bad attempt to compute absolute value of signed 32-bit hashcode (#2151)"
This reverts commit 3fb749a4e40fe65c82741ca2622c052707bfa3f7.
---
.../sharding/impl/RoundRobinByNameJobShardingStrategy.java | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/impl/RoundRobinByNameJobShardingStrategy.java b/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/impl/RoundRobinByNameJobShardingStrategy.java
index dfcf93702..a3cb679d5 100644
--- a/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/impl/RoundRobinByNameJobShardingStrategy.java
+++ b/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/impl/RoundRobinByNameJobShardingStrategy.java
@@ -38,13 +38,7 @@ public final class RoundRobinByNameJobShardingStrategy implements JobShardingStr
private List<JobInstance> rotateServerList(final List<JobInstance> shardingUnits, final String jobName) {
int shardingUnitsSize = shardingUnits.size();
- int jobHashCode = jobName.hashCode();
- int offset = 0;
- if (jobHashCode != Integer.MIN_VALUE) {
- offset = Math.abs(jobHashCode) % shardingUnitsSize;
- } else {
- offset = Integer.MIN_VALUE % shardingUnitsSize;
- }
+ int offset = Math.abs(jobName.hashCode()) % shardingUnitsSize;
if (0 == offset) {
return shardingUnits;
}