From e70eea8c1005489e649aa14bb9e6e563f4c18fca Mon Sep 17 00:00:00 2001 From: Nathan Doef Date: Wed, 1 Nov 2023 14:39:47 -0400 Subject: [PATCH] Revert "Issue 5418 support Boolean class return type in BaseInterceptorService (#5421)" This reverts commit 4e295a59fb143a2ba54bc44305474096e2acd578. --- .../executor/BaseInterceptorService.java | 14 ++++++-------- .../interceptor/executor/InterceptorService.java | 5 ----- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/interceptor/executor/BaseInterceptorService.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/interceptor/executor/BaseInterceptorService.java index 893350887076..07ac7df658bb 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/interceptor/executor/BaseInterceptorService.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/interceptor/executor/BaseInterceptorService.java @@ -263,12 +263,10 @@ public boolean hasHooks(POINTCUT thePointcut) { return myRegisteredPointcuts.contains(thePointcut); } - protected abstract Class getBooleanReturnType(); - @Override public boolean callHooks(POINTCUT thePointcut, HookParams theParams) { assert haveAppropriateParams(thePointcut, theParams); - assert thePointcut.getReturnType() == void.class || thePointcut.getReturnType() == getBooleanReturnType(); + assert thePointcut.getReturnType() == void.class || thePointcut.getReturnType() == boolean.class; Object retValObj = doCallHooks(thePointcut, theParams, true); return (Boolean) retValObj; @@ -284,14 +282,14 @@ private Object doCallHooks(POINTCUT thePointcut, HookParams theParams, Object th for (BaseInvoker nextInvoker : invokers) { Object nextOutcome = nextInvoker.invoke(theParams); Class pointcutReturnType = thePointcut.getReturnType(); - if (pointcutReturnType.equals(getBooleanReturnType())) { + if (pointcutReturnType.equals(boolean.class)) { Boolean nextOutcomeAsBoolean = (Boolean) nextOutcome; if (Boolean.FALSE.equals(nextOutcomeAsBoolean)) { ourLog.trace("callHooks({}) for invoker({}) returned false", thePointcut, nextInvoker); theRetVal = false; break; } - } else if (!pointcutReturnType.equals(void.class)) { + } else if (pointcutReturnType.equals(void.class) == false) { if (nextOutcome != null) { theRetVal = nextOutcome; break; @@ -351,7 +349,7 @@ private List union(List... theInvokersLists) { List retVal; - if (!haveMultiple) { + if (haveMultiple == false) { // The global list doesn't need to be sorted every time since it's sorted on // insertion each time. Doing so is a waste of cycles.. @@ -487,9 +485,9 @@ private HookInvoker( myMethod = theHookMethod; Class returnType = theHookMethod.getReturnType(); - if (myPointcut.getReturnType().equals(getBooleanReturnType())) { + if (myPointcut.getReturnType().equals(boolean.class)) { Validate.isTrue( - getBooleanReturnType().equals(returnType) || void.class.equals(returnType), + boolean.class.equals(returnType) || void.class.equals(returnType), "Method does not return boolean or void: %s", theHookMethod); } else if (myPointcut.getReturnType().equals(void.class)) { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/interceptor/executor/InterceptorService.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/interceptor/executor/InterceptorService.java index adf9bb1765bf..a1d8fb8875a7 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/interceptor/executor/InterceptorService.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/interceptor/executor/InterceptorService.java @@ -51,11 +51,6 @@ public InterceptorService(String theName) { super(Pointcut.class, theName); } - @Override - protected Class getBooleanReturnType() { - return boolean.class; - } - @Override protected Optional scanForHook(Method nextMethod) { return findAnnotation(nextMethod, Hook.class).map(t -> new HookDescriptor(t.value(), t.order()));