diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionCheckingSubscriber.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionCheckingSubscriber.java index 9a2c040c557..57afa81c05e 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionCheckingSubscriber.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionCheckingSubscriber.java @@ -9,9 +9,9 @@ package ca.uhn.fhir.jpa.subscription; * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -108,19 +108,16 @@ public class SubscriptionCheckingSubscriber extends BaseSubscriptionSubscriber { continue; } - // should just be one resource as it was filtered by the id - for (IBaseResource nextBase : results.getResources(0, results.size())) { - ourLog.info("Found match: queueing rest-hook notification for resource: {}", nextBase.getIdElement()); + ourLog.info("Found match: queueing rest-hook notification for resource: {}", id.toUnqualifiedVersionless().getValue()); - ResourceDeliveryMessage deliveryMsg = new ResourceDeliveryMessage(); - deliveryMsg.setPayload(getContext(), nextBase); - deliveryMsg.setSubscription(nextSubscription); - deliveryMsg.setOperationType(msg.getOperationType()); - deliveryMsg.setPayloadId(msg.getId(getContext())); + ResourceDeliveryMessage deliveryMsg = new ResourceDeliveryMessage(); + deliveryMsg.setPayload(getContext(), msg.getNewPayload(getContext())); + deliveryMsg.setSubscription(nextSubscription); + deliveryMsg.setOperationType(msg.getOperationType()); + deliveryMsg.setPayloadId(msg.getId(getContext())); - ResourceDeliveryJsonMessage wrappedMsg = new ResourceDeliveryJsonMessage(deliveryMsg); - getSubscriptionInterceptor().getDeliveryChannel().send(wrappedMsg); - } + ResourceDeliveryJsonMessage wrappedMsg = new ResourceDeliveryJsonMessage(deliveryMsg); + getSubscriptionInterceptor().getDeliveryChannel().send(wrappedMsg); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/StopWatch.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/StopWatch.java index 908068c928b..8928ffa8fe6 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/StopWatch.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/StopWatch.java @@ -107,8 +107,12 @@ public class StopWatch { tgt.append(val); } + /** + * @param theNumOperations Ok for this to be 0, it will be treated as 1 + */ public int getMillisPerOperation(int theNumOperations) { - return (int)(((double) getMillis()) / Math.max(1.0, theNumOperations)); + int numOperations = Math.min(1, theNumOperations); + return (int)(((double) getMillis()) / Math.max(1.0, numOperations)); } }