From 3068fe8c1aac329c0f2441a40b56f081fcc465c1 Mon Sep 17 00:00:00 2001 From: Tadgh Date: Sat, 1 Aug 2020 13:08:29 -0700 Subject: [PATCH] Rework escape hatch to error --- .../ca/uhn/fhir/jpa/empi/config/EmpiSubmitterConfig.java | 5 ++--- .../java/ca/uhn/fhir/jpa/empi/svc/EmpiPersonDeletingSvc.java | 5 ++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/config/EmpiSubmitterConfig.java b/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/config/EmpiSubmitterConfig.java index a2c1a0d7470..c9a22ce2d49 100644 --- a/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/config/EmpiSubmitterConfig.java +++ b/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/config/EmpiSubmitterConfig.java @@ -31,7 +31,6 @@ import ca.uhn.fhir.jpa.empi.svc.EmpiChannelSubmitterSvcImpl; import ca.uhn.fhir.jpa.empi.svc.EmpiPersonDeletingSvc; import ca.uhn.fhir.jpa.empi.svc.EmpiSearchParamSvc; import ca.uhn.fhir.jpa.subscription.channel.api.IChannelFactory; -import ca.uhn.fhir.jpa.subscription.channel.subscription.IChannelNamer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Lazy; @@ -66,8 +65,8 @@ public class EmpiSubmitterConfig { @Bean @Lazy - IEmpiChannelSubmitterSvc empiChannelSubmitterSvc(IChannelNamer theChannelNamer, FhirContext theFhirContext, IChannelFactory theChannelFactory) { - return new EmpiChannelSubmitterSvcImpl(theChannelNamer, theFhirContext, theChannelFactory); + IEmpiChannelSubmitterSvc empiChannelSubmitterSvc(FhirContext theFhirContext, IChannelFactory theChannelFactory) { + return new EmpiChannelSubmitterSvcImpl(theFhirContext, theChannelFactory); } @Bean diff --git a/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/svc/EmpiPersonDeletingSvc.java b/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/svc/EmpiPersonDeletingSvc.java index cd842fd89bf..6627d6977c7 100644 --- a/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/svc/EmpiPersonDeletingSvc.java +++ b/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/svc/EmpiPersonDeletingSvc.java @@ -65,9 +65,12 @@ public class EmpiPersonDeletingSvc { IFhirResourceDao personDao = myDaoRegistry.getResourceDao("Person"); int batchCount = 0; - while (!deleteConflictList.isEmpty() && batchCount < MAXIMUM_DELETE_ATTEMPTS) { + while (!deleteConflictList.isEmpty()) { deleteConflictBatch(deleteConflictList, personDao); batchCount += 1; + if (batchCount > MAXIMUM_DELETE_ATTEMPTS) { + throw new IllegalStateException("Person deletion seems to have entered an infinite loop. Aborting"); + } } }