From 17f03ac84320b67f3a60ea070b85b5cd8f2fe75e Mon Sep 17 00:00:00 2001 From: James Agnew Date: Sun, 20 Jan 2019 19:43:58 -0500 Subject: [PATCH] Allow null return type for interceptors --- .../fhir/jpa/interceptor/test/InterceptorRegistryTest.java | 5 +---- .../jpa/model/interceptor/executor/InterceptorRegistry.java | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/test/InterceptorRegistryTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/test/InterceptorRegistryTest.java index d1f6c0d9ead..de384608297 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/test/InterceptorRegistryTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/test/InterceptorRegistryTest.java @@ -26,7 +26,6 @@ import static org.junit.Assert.*; @ContextConfiguration(classes = {InterceptorRegistryTest.InterceptorRegistryTestCtxConfig.class}) public class InterceptorRegistryTest { - private static boolean ourNext_beforeRestHookDelivery_Return2; private static boolean ourNext_beforeRestHookDelivery_Return1; private static List ourInvocations = new ArrayList<>(); private static CanonicalSubscription ourLastCanonicalSubscription; @@ -88,7 +87,6 @@ public class InterceptorRegistryTest { @Before public void before() { ourNext_beforeRestHookDelivery_Return1 = true; - ourNext_beforeRestHookDelivery_Return2 = true; ourLastCanonicalSubscription = null; ourLastResourceDeliveryMessage0 = null; ourLastResourceDeliveryMessage1 = null; @@ -140,11 +138,10 @@ public class InterceptorRegistryTest { @Order(200) public static class MyTestInterceptorTwo { @Hook(Pointcut.SUBSCRIPTION_BEFORE_REST_HOOK_DELIVERY) - public boolean beforeRestHookDelivery(ResourceDeliveryMessage theResourceDeliveryMessage0, ResourceDeliveryMessage theResourceDeliveryMessage1) { + public void beforeRestHookDelivery(ResourceDeliveryMessage theResourceDeliveryMessage0, ResourceDeliveryMessage theResourceDeliveryMessage1) { ourLastResourceDeliveryMessage0 = theResourceDeliveryMessage0; ourLastResourceDeliveryMessage1 = theResourceDeliveryMessage1; ourInvocations.add("MyTestInterceptorTwo.beforeRestHookDelivery"); - return ourNext_beforeRestHookDelivery_Return2; } } diff --git a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/interceptor/executor/InterceptorRegistry.java b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/interceptor/executor/InterceptorRegistry.java index 14e3ed9c2a3..da86d6212a0 100644 --- a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/interceptor/executor/InterceptorRegistry.java +++ b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/interceptor/executor/InterceptorRegistry.java @@ -254,10 +254,10 @@ public class InterceptorRegistry implements IInterceptorRegistry, ApplicationCon myMethod = theHookMethod; Class returnType = theHookMethod.getReturnType(); - if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) { + if (returnType.equals(boolean.class)) { myReturnsBoolean = true; } else { - Validate.isTrue(Void.class.equals(returnType), "Method does not return boolean or void: %s", theHookMethod); + Validate.isTrue(void.class.equals(returnType), "Method does not return boolean or void: %s", theHookMethod); myReturnsBoolean = false; }