Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -351,7 +349,7 @@ private List<BaseInvoker> union(List<BaseInvoker>... theInvokersLists) {

List<BaseInvoker> 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..
Expand Down Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ public InterceptorService(String theName) {
super(Pointcut.class, theName);
}

@Override
protected Class<?> getBooleanReturnType() {
return boolean.class;
}

@Override
protected Optional<HookDescriptor> scanForHook(Method nextMethod) {
return findAnnotation(nextMethod, Hook.class).map(t -> new HookDescriptor(t.value(), t.order()));
Expand Down