You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by me...@apache.org on 2021/12/12 19:41:55 UTC

[shardingsphere] branch master updated: Refactor JDBCDataSourceCreatorFactory (#14065)

This is an automated email from the ASF dual-hosted git repository.

menghaoran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new e5d6778  Refactor JDBCDataSourceCreatorFactory (#14065)
e5d6778 is described below

commit e5d677828b8ef465cf10daf8a842083218a95faa
Author: Liang Zhang <te...@163.com>
AuthorDate: Mon Dec 13 03:41:11 2021 +0800

    Refactor JDBCDataSourceCreatorFactory (#14065)
    
    * Refactor JDBCDataSourceCreatorFactory
    
    * Refactor JDBCDataSourceCreatorFactory
---
 .../datasource/jdbc/creator/JDBCDataSourceCreatorFactory.java    | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/jdbc/creator/JDBCDataSourceCreatorFactory.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/jdbc/creator/JDBCDataSourceCreatorFactory.java
index 40c3f91..d131744 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/jdbc/creator/JDBCDataSourceCreatorFactory.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/jdbc/creator/JDBCDataSourceCreatorFactory.java
@@ -17,12 +17,9 @@
 
 package org.apache.shardingsphere.infra.config.datasource.jdbc.creator;
 
-import com.google.common.base.Preconditions;
 import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
 import org.apache.shardingsphere.spi.typed.TypedSPIRegistry;
 
-import java.util.Optional;
-
 /**
  * JDBC data source creator factory.
  */
@@ -35,12 +32,10 @@ public final class JDBCDataSourceCreatorFactory {
     /**
      * Get JDBC data source creator instance.
      * 
-     * @param type type
+     * @param type JDBC data source creator type
      * @return JDBC data source creator instance
      */
     public static JDBCDataSourceCreator getInstance(final String type) {
-        Optional<JDBCDataSourceCreator> result = TypedSPIRegistry.findRegisteredService(JDBCDataSourceCreator.class, type, null);
-        Preconditions.checkArgument(result.isPresent(), "Unsupported data source type '%s'", type);
-        return result.get();
+        return TypedSPIRegistry.getRegisteredService(JDBCDataSourceCreator.class, type, null);
     }
 }