From 2fc7e5e6749f81b5801dbb365620099b98d74d94 Mon Sep 17 00:00:00 2001 From: igor nitto Date: Tue, 10 Apr 2018 16:02:03 +0100 Subject: [PATCH] Classloader loading DataSource must stay open [ENT-1717] (#709) --- .../main/kotlin/net/corda/node/internal/DataSourceFactory.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/src/main/kotlin/net/corda/node/internal/DataSourceFactory.kt b/node/src/main/kotlin/net/corda/node/internal/DataSourceFactory.kt index 42a56e3955..11c75bd1e6 100644 --- a/node/src/main/kotlin/net/corda/node/internal/DataSourceFactory.kt +++ b/node/src/main/kotlin/net/corda/node/internal/DataSourceFactory.kt @@ -58,7 +58,7 @@ object DataSourceFactory { } fun createDatasourceFromDriverJarFolders(dataSourceProperties: Properties, baseClassLoader: ClassLoader, driverJarsPath: List): 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 dataSourceClass = driversClassLoader.loadClass(dataSourceClassName) val dataSourceInstance = dataSourceClass.newInstance() as DataSource