From e359b6d8230e87ff8e8b7557176fbf611a63d1ee Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Wed, 19 May 2021 09:45:04 -0400 Subject: [PATCH] Handle missing contained subscription --- .../match/registry/SubscriptionCanonicalizer.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/registry/SubscriptionCanonicalizer.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/registry/SubscriptionCanonicalizer.java index 5e852570c48..c7aec9d309b 100644 --- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/registry/SubscriptionCanonicalizer.java +++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/registry/SubscriptionCanonicalizer.java @@ -354,6 +354,7 @@ public class SubscriptionCanonicalizer { } @SuppressWarnings("EnumSwitchStatementWhichMissesCases") + @Nullable public String getCriteria(IBaseResource theSubscription) { String retVal = null; @@ -371,7 +372,10 @@ public class SubscriptionCanonicalizer { org.hl7.fhir.r5.model.Subscription subscription = (org.hl7.fhir.r5.model.Subscription) theSubscription; String topicElement = subscription.getTopicElement().getValue(); org.hl7.fhir.r5.model.SubscriptionTopic topic = (org.hl7.fhir.r5.model.SubscriptionTopic) subscription.getContained().stream().filter(t -> ("#" + t.getId()).equals(topicElement) || (t.getId()).equals(topicElement)).findFirst().orElse(null); - Validate.notNull(topic); + if (topic == null) { + ourLog.warn("Missing contained subscription topic in R5 subscription"); + return null; + } retVal = topic.getResourceTriggerFirstRep().getQueryCriteria().getCurrent(); break; }