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:59:00 UTC

[shardingsphere-elasticjob] branch master updated: Revert "Bug: Bad attempt to compute absolute value of signed 32-bit hashcode (#2151)" (#2160)

This is an automated email from the ASF dual-hosted git repository.

wuweijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob.git


The following commit(s) were added to refs/heads/master by this push:
     new 2fb71cf48 Revert "Bug: Bad attempt to compute absolute value of signed 32-bit hashcode (#2151)" (#2160)
2fb71cf48 is described below

commit 2fb71cf481121223b4ac95c437f8c66f5c6e71a9
Author: 吴伟杰 <wu...@apache.org>
AuthorDate: Tue Dec 6 22:58:54 2022 +0800

    Revert "Bug: Bad attempt to compute absolute value of signed 32-bit hashcode (#2151)" (#2160)
    
    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;
         }