terrymanu commented on a change in pull request #12268:
URL: https://github.com/apache/shardingsphere/pull/12268#discussion_r703469010



##########
File path: 
shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/creator/impl/HikariDataSourceCreator.java
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.config.datasource.creator.impl;
+
+import 
org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
+
+import javax.sql.DataSource;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Hikari data source creator.
+ */
+public final class HikariDataSourceCreator extends AbstractDataSourceCreator {
+    
+    private final Map<String, Object> skippedProperties = new HashMap<>();
+    
+    public HikariDataSourceCreator() {
+        skippedProperties.put("minimumIdle", -1);
+        skippedProperties.put("maximumPoolSize", -1);
+    }
+    
+    @Override
+    public DataSource createDataSource(final DataSourceConfiguration 
dataSourceConfiguration) {
+        DataSource result = 
buildDataSource(dataSourceConfiguration.getDataSourceClassName());
+        Method[] methods = result.getClass().getMethods();
+        for (Map.Entry<String, Object> entry : 
dataSourceConfiguration.getAllProps().entrySet()) {
+            if (isInvalidProperty(entry.getKey(), entry.getValue())) {
+                continue;
+            }
+            setField(result, methods, entry.getKey(), entry.getValue());
+        }
+        return result;
+    }
+    
+    private boolean isInvalidProperty(final String property, final Object 
value) {
+        return skippedProperties.containsKey(property) && null != value 
+                && value.equals(skippedProperties.get(property));

Review comment:
       Please keep one line if not exceed 200

##########
File path: 
shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/creator/impl/HikariDataSourceCreator.java
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.config.datasource.creator.impl;
+
+import 
org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
+
+import javax.sql.DataSource;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Hikari data source creator.
+ */
+public final class HikariDataSourceCreator extends AbstractDataSourceCreator {
+    
+    private final Map<String, Object> skippedProperties = new HashMap<>();
+    
+    public HikariDataSourceCreator() {
+        skippedProperties.put("minimumIdle", -1);
+        skippedProperties.put("maximumPoolSize", -1);
+    }
+    
+    @Override
+    public DataSource createDataSource(final DataSourceConfiguration 
dataSourceConfiguration) {
+        DataSource result = 
buildDataSource(dataSourceConfiguration.getDataSourceClassName());
+        Method[] methods = result.getClass().getMethods();
+        for (Map.Entry<String, Object> entry : 
dataSourceConfiguration.getAllProps().entrySet()) {

Review comment:
       Please use import for `Map.Entry`




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