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

Fix for Github issue dealing with duplicate property keys #2351

Merged
merged 4 commits into from Feb 17, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -132,14 +132,23 @@ public void set(String key, String value, ContextExpression contexts, Labels lab
changeLog));
} else {
ChangeLogParameter param = findParameter(key, changeLog);
if (param != null && ! param.isGlobal() && param.getChangeLog() == changeLog) {
if (param != null && isDuplicate(param) && ! param.isGlobal() && param.getChangeLog() == changeLog) {
changeLogParameters.remove(param);
}
//this is a non-global param, just add it
changeLogParameters.add(new ChangeLogParameter(key, value, contexts, labels, databases, globalParam, changeLog));
}
}

private boolean isDuplicate(ChangeLogParameter param) {
for (ChangeLogParameter parameter : changeLogParameters) {
if (param != parameter && param.isDuplicate(parameter)) {
return true;
}
}
return false;
}

/**
* Return the value of a parameter
*
Expand Down Expand Up @@ -343,6 +352,19 @@ public boolean isValid() {
return isValid;
}

public boolean isDuplicate(ChangeLogParameter other) {
String contextString = (this.getValidContexts() != null ? this.getValidContexts().toString() : null);
String labelsString = (this.getLabels() != null ? this.getLabels().toString() : null);
String databases = (this.getValidDatabases() != null ? StringUtil.join(this.getValidDatabases(), ",") : null);

String otherContextString = (other.getValidContexts() != null ? other.getValidContexts().toString() : null);
String otherLabelsString = (other.getLabels() != null ? other.getLabels().toString() : null);
String otherDatabases = (other.getValidDatabases() != null ? StringUtil.join(other.getValidDatabases(), ",") : null);
return StringUtil.equalsIgnoreCaseAndEmpty(contextString, otherContextString) &&
StringUtil.equalsIgnoreCaseAndEmpty(labelsString, otherLabelsString) &&
StringUtil.equalsIgnoreCaseAndEmpty(databases, otherDatabases);
}

public boolean isGlobal() {
return global;
}
Expand Down