You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/01/18 07:05:07 UTC

[GitHub] [shardingsphere] TeslaCN commented on a change in pull request #14856: Fix weight load balance throw IndexOutOfBoundsException.

TeslaCN commented on a change in pull request #14856:
URL: https://github.com/apache/shardingsphere/pull/14856#discussion_r786461913



##########
File path: shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/WeightReplicaLoadBalanceAlgorithm.java
##########
@@ -53,6 +53,9 @@ public String getDataSource(final String name, final String writeDataSourceName,
     }
 
     private String getDataSourceName(final List<String> readDataSourceNames, final double[] weight) {
+        if (1 == readDataSourceNames.size()) {
+            return readDataSourceNames.stream().findFirst().get();

Review comment:
       Why not just `get(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: notifications-unsubscribe@shardingsphere.apache.org

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