TeslaCN commented on code in PR #2151:
URL: 
https://github.com/apache/shardingsphere-elasticjob/pull/2151#discussion_r1034212910


##########
elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/handler/sharding/impl/RoundRobinByNameJobShardingStrategy.java:
##########
@@ -38,7 +38,13 @@ public Map<JobInstance, List<Integer>> sharding(final 
List<JobInstance> jobInsta
     
     private List<JobInstance> rotateServerList(final List<JobInstance> 
shardingUnits, final String jobName) {
         int shardingUnitsSize = shardingUnits.size();
-        int offset = Math.abs(jobName.hashCode()) % shardingUnitsSize;
+        int jobHashCode = jobName.hashCode();
+        int offset = 0;
+        if (jobHashCode != Integer.MIN_VALUE) {
+            offset = Math.abs(jobHashCode) % shardingUnitsSize;
+        } else {
+            offset = Integer.MIN_VALUE % shardingUnitsSize;
+        }

Review Comment:
   Hi @zume0127 
   Could you complete the tests 
`org.apache.shardingsphere.elasticjob.infra.handler.sharding.impl.RotateServerByNameJobShardingStrategyTest`
 for your logic?



-- 
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-unsubscr...@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to