diff --git a/extensions/datasource/deployment/src/main/java/io/quarkus/datasource/deployment/devservices/DevServicesDatasourceProcessor.java b/extensions/datasource/deployment/src/main/java/io/quarkus/datasource/deployment/devservices/DevServicesDatasourceProcessor.java index 0129e211c4c79..b254874043b5d 100644 --- a/extensions/datasource/deployment/src/main/java/io/quarkus/datasource/deployment/devservices/DevServicesDatasourceProcessor.java +++ b/extensions/datasource/deployment/src/main/java/io/quarkus/datasource/deployment/devservices/DevServicesDatasourceProcessor.java @@ -2,7 +2,6 @@ import java.io.Closeable; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -42,6 +41,7 @@ import io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem; import io.quarkus.runtime.LaunchMode; import io.quarkus.runtime.configuration.ConfigUtils; +import io.smallrye.config.SmallRyeConfig; @BuildSteps(onlyIfNot = IsNormal.class, onlyIf = GlobalDevServicesConfig.Enabled.class) public class DevServicesDatasourceProcessor { @@ -51,8 +51,7 @@ public class DevServicesDatasourceProcessor { // list of devservices properties we should not check for restart // see issue #30390 - private static final Set EXCLUDED_PROPERTIES = Set.of("quarkus.datasource.devservices.enabled", - "quarkus.datasource.devservices.reuse"); + private static final Set EXCLUDED_PROPERTIES = Set.of("quarkus.datasource.devservices.enabled"); static volatile List databases; @@ -79,24 +78,21 @@ DevServicesDatasourceResultBuildItem launchDatabases( //if not and the DB's have already started we just return if (databases != null) { boolean restartRequired = false; + Map newDatasourceConfigs = ConfigProvider.getConfig() + .unwrap(SmallRyeConfig.class) + .getOptionalValues("quarkus.datasource", + String.class, String.class) + .orElse(Map.of()); for (Map.Entry entry : cachedProperties.entrySet()) { - String value = ConfigProvider.getConfig() - .getOptionalValue(entry.getKey(), String.class) - .orElse(null); - if (value == null) { - value = getValueWithOrWithoutQuotes(entry.getKey(), - dataSourcesBuildTimeConfig.dataSources().keySet()); - } - if (!Objects.equals(entry.getValue(), trim(value))) { + String newValue = newDatasourceConfigs.get(entry.getKey()); + if (!Objects.equals(entry.getValue(), trim(newValue))) { restartRequired = true; break; } } if (!restartRequired) { - //devservices properties may have been added - for (var name : ConfigProvider.getConfig().getPropertyNames()) { - if (name.startsWith("quarkus.datasource.") && name.contains(".devservices.") - && !cachedProperties.containsKey(name) && !EXCLUDED_PROPERTIES.contains(name)) { + for (var name : newDatasourceConfigs.keySet()) { + if (!cachedProperties.containsKey(name)) { restartRequired = true; break; } @@ -178,41 +174,16 @@ public void run() { closeBuildItem.addCloseTask(closeTask, true); } databases = runningDevServices; - cachedProperties = propertiesMap; + cachedProperties = ConfigProvider.getConfig() + .unwrap(SmallRyeConfig.class) + .getOptionalValues("quarkus.datasource", String.class, String.class) + .orElse(Map.of()); for (RunningDevService database : databases) { devServicesResultBuildItemBuildProducer.produce(database.toBuildItem()); } return new DevServicesDatasourceResultBuildItem(results); } - /** - * Gets the value of the given key trying to quote the datasource if unquoted, and unquote it if quoted - * - * @param key key to get - * @param datasources datasources to try to quote and unqote - * @return the value or else otherwise - */ - private static String getValueWithOrWithoutQuotes(String key, Collection datasources) { - for (String datasource : datasources) { - if (!DataSourceUtil.isDefault(datasource) && key.contains(datasource)) { - String quoted = ".\"" + datasource + "\"."; - String unquoted = "." + datasource + "."; - if (key.contains(quoted)) { - String entryWithoutQuote = key.replace(quoted, unquoted); - return ConfigProvider.getConfig() - .getOptionalValue(entryWithoutQuote, String.class) - .orElse(null); - } else { - String entryWithQuotes = key.replace(unquoted, quoted); - return ConfigProvider.getConfig() - .getOptionalValue(entryWithQuotes, String.class) - .orElse(null); - } - } - } - return null; - } - private String trim(String optional) { if (optional == null) { return null;