QiangYuan0828 commented on code in PR #24934:
URL: https://github.com/apache/shardingsphere/pull/24934#discussion_r1170846104


##########
features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/WeightReadQueryLoadBalanceAlgorithm.java:
##########
@@ -50,6 +51,17 @@ public final class WeightReadQueryLoadBalanceAlgorithm 
implements ReadQueryLoadB
     public void init(final Properties props) {
         this.props = props;
         dataSourceNames = props.stringPropertyNames();
+        ShardingSpherePreconditions.checkState(!dataSourceNames.isEmpty(), () 
-> new ReadQueryLoadBalanceAlgorithmInitializationExcpetion(getType(), "data 
source shouldn't be empty!"));
+        for (String dataSourceName : dataSourceNames) {
+            Object weightObject = props.get(dataSourceName);
+            ShardingSpherePreconditions.checkNotNull(weightObject,
+                    () -> new 
MissingRequiredReadDatabaseWeightException(getType(), String.format("Read 
database `%s` access weight is not configured.", dataSourceName)));
+            try {
+                Double.parseDouble(weightObject.toString());
+            } catch (final NumberFormatException ex) {
+                throw new InvalidReadDatabaseWeightException(weightObject);
+            }
+        }

Review Comment:
   Thanks for your suggestions. Already modified.



-- 
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]

Reply via email to