From 1d4f1e9d9038aca3b828a3ebdb0ad938cb2bb03e Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Mon, 6 Feb 2023 05:38:02 +1100 Subject: [PATCH] fix bug with duplicate value in getResourceNames() --- .../java/org/hl7/fhir/r5/context/SimpleWorkerContext.java | 7 ++++--- .../src/main/java/org/hl7/fhir/utilities/Utilities.java | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java index e4484c10f..493922ce4 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java @@ -37,9 +37,11 @@ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Set; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -560,13 +562,12 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon @Override public List getResourceNames() { - List result = new ArrayList(); + Set result = new HashSet(); for (StructureDefinition sd : listStructures()) { if (sd.getKind() == StructureDefinitionKind.RESOURCE && sd.getDerivation() == TypeDerivationRule.SPECIALIZATION) result.add(sd.getName()); } - Collections.sort(result); - return result; + return Utilities.sorted(result); } diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java index dcafaf727..508bbcb1d 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java @@ -1297,7 +1297,7 @@ public class Utilities { return id.matches("[A-Za-z0-9\\-\\.]{1,64}"); } - public static List sorted(Set set) { + public static List sorted(Collection set) { List list = new ArrayList<>(); list.addAll(set); Collections.sort(list);