Skip to content

Commit

Permalink
#28251 dupe key was breaking endpoint. merge function added
Browse files Browse the repository at this point in the history
  • Loading branch information
fabrizzio-dotCMS committed May 17, 2024
1 parent 53384c9 commit ef628e3
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,12 @@ public Response getAllMessages (
// Enhanced Language Vars
final List<LanguageVariable> variables = languageVariableAPI.findVariables(matchingLang.getId());
final Map<?,?> map = variables.stream().collect(
Collectors.toMap(LanguageVariable::key, LanguageVariable::value));
Collectors.toMap(LanguageVariable::key, LanguageVariable::value, (value1,value2) ->{
//Merge function is always a good idea to have.
//There can be cases on which the "unique" constraint of the key is lifted allowing for duplicates
Logger.warn(this.getClass(),"Duplicate language variable found using latest value: " + value1);
return value1;
}));
result.putAll(map);
} else {
//Language Keys
Expand Down

0 comments on commit ef628e3

Please sign in to comment.