Classloader loading DataSource must stay open [ENT-1717] (#709)

This commit is contained in:
igor nitto 2018-04-10 16:02:03 +01:00 committed by GitHub
parent f022c67689
commit 2fc7e5e674
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -58,7 +58,7 @@ object DataSourceFactory {
} }
fun createDatasourceFromDriverJarFolders(dataSourceProperties: Properties, baseClassLoader: ClassLoader, driverJarsPath: List<Path>): DataSource { fun createDatasourceFromDriverJarFolders(dataSourceProperties: Properties, baseClassLoader: ClassLoader, driverJarsPath: List<Path>): DataSource {
return URLClassLoader(driverJarsPath.flatMap { Files.newDirectoryStream(it, "*.jar") }.map { it.toUri().toURL() }.toTypedArray(), baseClassLoader).use { driversClassLoader -> return URLClassLoader(driverJarsPath.flatMap { Files.newDirectoryStream(it, "*.jar") }.map { it.toUri().toURL() }.toTypedArray(), baseClassLoader).let { driversClassLoader ->
val dataSourceClassName = dataSourceProperties["dataSourceClassName"] as String? val dataSourceClassName = dataSourceProperties["dataSourceClassName"] as String?
val dataSourceClass = driversClassLoader.loadClass(dataSourceClassName) val dataSourceClass = driversClassLoader.loadClass(dataSourceClassName)
val dataSourceInstance = dataSourceClass.newInstance() as DataSource val dataSourceInstance = dataSourceClass.newInstance() as DataSource