bowenliang123 commented on code in PR #4905:
URL: https://github.com/apache/kyuubi/pull/4905#discussion_r1210317136
##########
externals/kyuubi-jdbc-engine/src/main/scala/org/apache/kyuubi/engine/jdbc/connection/ConnectionProvider.scala:
##########
@@ -69,27 +69,12 @@ abstract class AbstractConnectionProvider extends Logging {
selectedProvider.getConnection(kyuubiConf)
}
- def loadProviders(): Seq[JdbcConnectionProvider] = {
- val loader = ServiceLoader.load(
- classOf[JdbcConnectionProvider],
- Thread.currentThread().getContextClassLoader)
- val providers = ArrayBuffer[JdbcConnectionProvider]()
-
- val iterator = loader.iterator()
- while (iterator.hasNext) {
- try {
- val provider = iterator.next()
+ def loadProviders(): Seq[JdbcConnectionProvider] =
+ loadClassFromServiceLoader[JdbcConnectionProvider]()
+ .map { provider =>
info(s"Loaded provider: $provider")
- providers += provider
- } catch {
- case t: Throwable =>
- warn(s"Loaded of the provider failed with the exception", t)
- }
- }
-
- // TODO support disable provider
- providers
- }
+ provider
+ }.toSeq
Review Comment:
Could you have a look at this change? Trying to simplify the loading and
looping of JdbcConnectionProvider. And skipping the warning message as there's
no instance construction and no possible thrown exception.
cc @zhouyifan279
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]