Pace2Car commented on code in PR #24934:
URL: https://github.com/apache/shardingsphere/pull/24934#discussion_r1169435862
##########
features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/RandomReadQueryLoadBalanceAlgorithm.java:
##########
@@ -29,7 +30,10 @@ public final class RandomReadQueryLoadBalanceAlgorithm
implements ReadQueryLoadB
@Override
public String getDataSource(final String name, final String
writeDataSourceName, final List<String> readDataSourceNames) {
- return
readDataSourceNames.get(ThreadLocalRandom.current().nextInt(readDataSourceNames.size()));
+ Preconditions.checkState(readDataSourceNames.size() > 0, "read data
need at least 1 source.");
Review Comment:
Ok, I reorganized it, here should revert the first commit, the goal of this
issue is to improve check in `init` method.
> As for the algorithm that does not implement the `init` method, it can be
ignored, I will modify the issue tasks. Thanks for pointing out
--
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]