Patch response should sort the owners field (#17599)

This commit is contained in:
Sriharsha Chintalapani 2024-08-27 11:02:12 -07:00 committed by GitHub
parent 19b5d49dc8
commit 94f0c1144e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -84,6 +84,7 @@ import java.time.format.DateTimeParseException;
import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAccessor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -1981,6 +1982,12 @@ public abstract class EntityRepository<T extends EntityInterface> {
} }
// populate owner entityRefs with all fields // populate owner entityRefs with all fields
List<EntityReference> refs = validateOwners(owners); List<EntityReference> refs = validateOwners(owners);
if (nullOrEmpty(refs)) {
return;
}
refs.sort(Comparator.comparing(EntityReference::getName));
owners.sort(Comparator.comparing(EntityReference::getName));
for (int i = 0; i < owners.size(); i++) { for (int i = 0; i < owners.size(); i++) {
EntityUtil.copy(refs.get(i), owners.get(i)); EntityUtil.copy(refs.get(i), owners.get(i));
} }