From b06105d97066dc1fa91caf0facec7c9b142717b3 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Mon, 3 Feb 2020 18:06:29 -0500 Subject: [PATCH] Intermittent test fix --- .../SubscriptionTriggeringSvcImpl.java | 16 +++++++++++++--- .../SubscriptionTriggeringDstu3Test.java | 3 +-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionTriggeringSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionTriggeringSvcImpl.java index 7cbf4ec0650..49506449095 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionTriggeringSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionTriggeringSvcImpl.java @@ -66,7 +66,13 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.UUID; -import java.util.concurrent.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.RejectedExecutionException; +import java.util.concurrent.RejectedExecutionHandler; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import static ca.uhn.fhir.jpa.provider.SubscriptionTriggeringProvider.RESOURCE_ID; @@ -136,8 +142,8 @@ public class SubscriptionTriggeringSvcImpl implements ISubscriptionTriggeringSvc SubscriptionTriggeringJobDetails jobDetails = new SubscriptionTriggeringJobDetails(); jobDetails.setJobId(UUID.randomUUID().toString()); - jobDetails.setRemainingResourceIds(resourceIds.stream().map(t->t.getValue()).collect(Collectors.toList())); - jobDetails.setRemainingSearchUrls(searchUrls.stream().map(t->t.getValue()).collect(Collectors.toList())); + jobDetails.setRemainingResourceIds(resourceIds.stream().map(t -> t.getValue()).collect(Collectors.toList())); + jobDetails.setRemainingSearchUrls(searchUrls.stream().map(t -> t.getValue()).collect(Collectors.toList())); if (theSubscriptionId != null) { jobDetails.setSubscriptionId(theSubscriptionId.getIdPart()); } @@ -391,6 +397,10 @@ public class SubscriptionTriggeringSvcImpl implements ISubscriptionTriggeringSvc mySchedulerService.scheduleLocalJob(5 * DateUtils.MILLIS_PER_SECOND, jobDetail); } + public int getActiveJobCount() { + return myActiveJobs.size(); + } + public static class Job implements HapiJob { @Autowired private ISubscriptionTriggeringSvc myTarget; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/SubscriptionTriggeringDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/SubscriptionTriggeringDstu3Test.java index 200b90c3aa7..a4656d2a010 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/SubscriptionTriggeringDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/SubscriptionTriggeringDstu3Test.java @@ -264,8 +264,6 @@ public class SubscriptionTriggeringDstu3Test extends BaseResourceProviderDstu3Te @Test public void testTriggerUsingOrSeparatedList_MultipleStrings() throws Exception { - myDaoConfig.setSearchPreFetchThresholds(Lists.newArrayList(13, 22, 100)); - String payload = "application/fhir+json"; IdType sub2id = createSubscription("Patient?", payload, ourListenerServerBase).getIdElement(); @@ -299,6 +297,7 @@ public class SubscriptionTriggeringDstu3Test extends BaseResourceProviderDstu3Te mySubscriptionTriggeringSvc.runDeliveryPass(); mySubscriptionTriggeringSvc.runDeliveryPass(); mySubscriptionTriggeringSvc.runDeliveryPass(); + assertEquals(0, mySubscriptionTriggeringSvc.getActiveJobCount()); assertEquals(0, ourCreatedPatients.size()); assertEquals(ourUpdatedPatients.stream().map(t->t.getId()).collect(Collectors.joining(", ")), 3, ourUpdatedPatients.size());