Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CB-4949 merge runtime and root config in original properties #2667

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading