Skip to content

Commit

Permalink
CB-4949 merge runtime and root config in original properties (#2667)
Browse files Browse the repository at this point in the history
Co-authored-by: Daria Marutkina <[email protected]>
  • Loading branch information
alexander-skoblikov and dariamarutkina authored May 27, 2024
1 parent 0151edf commit c893e47
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,16 @@ public static SMAuthenticationManager getAuthManager(WebApplication application)
}

@SuppressWarnings("unchecked")
public static Map<String, Object> mergeConfigurations(Map<String, Object> origin, Map<String, Object> additional) {
public static Map<String, Object> mergeConfigurations(
Map<String, Object> priorityConfiguration,
Map<String, Object> additional
) {
var resultConfig = new HashMap<String, Object>();
Set<String> rootKeys = new HashSet<>(origin.keySet());
Set<String> rootKeys = new HashSet<>(priorityConfiguration.keySet());
rootKeys.addAll(additional.keySet());

for (var rootKey : rootKeys) {
var originValue = origin.get(rootKey);
var originValue = priorityConfiguration.get(rootKey);
var additionalValue = additional.get(rootKey);

if (originValue == null || additionalValue == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,13 @@ protected Map<String, Object> readConfiguration(Path configPath) throws DBExcept
Map<String, Object> configProps = new LinkedHashMap<>();
if (Files.exists(configPath)) {
log.debug("Read configuration [" + configPath.toAbsolutePath() + "]");

configProps.putAll(readConfigurationFile(configPath));

var mergedOriginalConfigs = WebAppUtils.mergeConfigurations(configProps, originalConfigurationProperties);
this.originalConfigurationProperties.clear();
// saves original configuration file
this.originalConfigurationProperties.putAll(readConfigurationFile(configPath));
this.originalConfigurationProperties.putAll(mergedOriginalConfigs);

configProps.putAll(readConfigurationFile(configPath));
patchConfigurationWithProperties(configProps); // patch original properties
Expand Down

0 comments on commit c893e47

Please sign in to comment.