From 94f0c1144e11eeb1dcadffe648b66a1d672c9273 Mon Sep 17 00:00:00 2001 From: Sriharsha Chintalapani Date: Tue, 27 Aug 2024 11:02:12 -0700 Subject: [PATCH] Patch response should sort the owners field (#17599) --- .../org/openmetadata/service/jdbi3/EntityRepository.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java index 01486609ce1..2b19546dcd4 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java @@ -84,6 +84,7 @@ import java.time.format.DateTimeParseException; import java.time.temporal.TemporalAccessor; import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -1981,6 +1982,12 @@ public abstract class EntityRepository { } // populate owner entityRefs with all fields List 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++) { EntityUtil.copy(refs.get(i), owners.get(i)); }