diff --git a/src/main/java/cz/cvut/kbss/termit/util/throttle/ThrottleAspect.java b/src/main/java/cz/cvut/kbss/termit/util/throttle/ThrottleAspect.java index 68b384f6f..2755d9558 100644 --- a/src/main/java/cz/cvut/kbss/termit/util/throttle/ThrottleAspect.java +++ b/src/main/java/cz/cvut/kbss/termit/util/throttle/ThrottleAspect.java @@ -150,7 +150,7 @@ private static StandardEvaluationContext makeDefaultContext() { * @throws IllegalCallerException when the annotated method returns another type than {@code void}, {@link Void} or {@link Future} * @implNote Around advice configured in {@code spring-aop.xml} */ - public synchronized @Nullable Object throttleMethodCall(@NotNull ProceedingJoinPoint joinPoint, + public @Nullable Object throttleMethodCall(@NotNull ProceedingJoinPoint joinPoint, @NotNull Throttle throttleAnnotation) throws Throwable { // if the current thread is already executing a throttled code, we want to skip further throttling @@ -165,6 +165,12 @@ private static StandardEvaluationContext makeDefaultContext() { return result; } + return doThrottle(joinPoint, throttleAnnotation); + } + + private synchronized @Nullable Object doThrottle(@NotNull ProceedingJoinPoint joinPoint, + @NotNull Throttle throttleAnnotation) throws Throwable { + final MethodSignature signature = (MethodSignature) joinPoint.getSignature(); // construct the throttle instance key