From f853dcf148de394a38182444dc185260456d09c5 Mon Sep 17 00:00:00 2001 From: Ainur Date: Wed, 6 Mar 2024 15:39:11 +0100 Subject: [PATCH 1/2] CB-4816 refresh disabled drivers after loading runtime config --- .../src/io/cloudbeaver/server/CBApplication.java | 15 ++++++++++++++- .../src/io/cloudbeaver/server/CBPlatform.java | 14 -------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBApplication.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBApplication.java index 7c394e34c4..063fb9cfe9 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBApplication.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBApplication.java @@ -48,6 +48,7 @@ import org.jkiss.dbeaver.model.app.DBPPlatform; import org.jkiss.dbeaver.model.auth.AuthInfo; import org.jkiss.dbeaver.model.auth.SMCredentialsProvider; +import org.jkiss.dbeaver.model.connection.DBPDriver; import org.jkiss.dbeaver.model.data.json.JSONUtils; import org.jkiss.dbeaver.model.navigator.DBNBrowseSettings; import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor; @@ -541,7 +542,7 @@ protected Path loadServerConfiguration() throws DBException { log.debug("Runtime configuration [" + runtimeConfigFile.getAbsolutePath() + "]"); parseConfiguration(runtimeConfigFile); } - + refreshDisabledDriversConfig(); return path; } @@ -1338,4 +1339,16 @@ protected void sendConfigChangedEvent(SMCredentialsProvider credentialsProvider) } eventController.addEvent(new WSServerConfigurationChangedEvent(sessionId, null)); } + + private void refreshDisabledDriversConfig() { + CBAppConfig config = getAppConfiguration(); + Set disabledDrivers = new LinkedHashSet<>(Arrays.asList(config.getDisabledDrivers())); + for (DBPDriver driver : CBPlatform.getInstance().getApplicableDrivers()) { + if (!driver.isEmbedded() || config.isDriverForceEnabled(driver.getFullId())) { + continue; + } + disabledDrivers.add(driver.getFullId()); + } + config.setDisabledDrivers(disabledDrivers.toArray(new String[0])); + } } diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBPlatform.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBPlatform.java index b01af47eb2..d281748bac 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBPlatform.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBPlatform.java @@ -119,8 +119,6 @@ protected synchronized void initialize() { refreshApplicableDrivers(); - refreshDisabledDriversConfig(); - new WebSessionMonitorJob(this) .scheduleMonitor(); @@ -293,18 +291,6 @@ public void refreshApplicableDrivers() { log.info("Available drivers: " + applicableDrivers.stream().map(DBPDriver::getFullName).collect(Collectors.joining(","))); } - private void refreshDisabledDriversConfig() { - CBAppConfig config = application.getAppConfiguration(); - Set disabledDrivers = new LinkedHashSet<>(Arrays.asList(config.getDisabledDrivers())); - for (DBPDriver driver : applicableDrivers) { - if (!driver.isEmbedded() || config.isDriverForceEnabled(driver.getFullId())) { - continue; - } - disabledDrivers.add(driver.getFullId()); - } - config.setDisabledDrivers(disabledDrivers.toArray(new String[0])); - } - @NotNull @Override public DBFileController createFileController() { From 758fc383a7c1eb2bb763b4b9bc64d398dbf9e668 Mon Sep 17 00:00:00 2001 From: Ainur Date: Wed, 6 Mar 2024 15:48:52 +0100 Subject: [PATCH 2/2] CB-4816 refresh drivers config only when starting server --- .../src/io/cloudbeaver/server/CBApplication.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBApplication.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBApplication.java index 063fb9cfe9..0b1653bf36 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBApplication.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/CBApplication.java @@ -261,6 +261,7 @@ protected void startServer() { log.error(e); return; } + refreshDisabledDriversConfig(); configurationMode = CommonUtils.isEmpty(serverName); @@ -542,7 +543,6 @@ protected Path loadServerConfiguration() throws DBException { log.debug("Runtime configuration [" + runtimeConfigFile.getAbsolutePath() + "]"); parseConfiguration(runtimeConfigFile); } - refreshDisabledDriversConfig(); return path; }