Skip to content

Commit

Permalink
Make Spring integration with InterceptMode.PROXY_METHOD work for Spri…
Browse files Browse the repository at this point in the history
…ng versions prior to 5.0.0.
  • Loading branch information
ellebrecht committed Dec 6, 2024
1 parent 6b392f0 commit a63ccec
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,35 @@ class MethodProxyScheduledLockAdvisor extends AbstractPointcutAdvisor {

@NonNull
private static AnnotationMatchingPointcut methodPointcutFor(Class<? extends Annotation> methodAnnotationType) {
Integer springVersion = getSpringMajorVersion();
if (springVersion != null) {
if (springVersion < 2) {
throw new IllegalStateException("Spring < 2.x is not supported");
}
if (springVersion < 5) {
return new AnnotationMatchingPointcut(
null,
methodAnnotationType
);
}
}
return new AnnotationMatchingPointcut(
null,
methodAnnotationType,
true
);
}

private static Integer getSpringMajorVersion() {
try {
String springVersion = SpringVersion.getVersion();
int dot = springVersion.indexOf('.');
return dot > 0 ? Integer.parseInt(springVersion.substring(0, dot)) : Integer.parseInt(springVersion);
} catch (NumberFormatException | NullPointerException e) {
return null;
}
}

/**
* Get the Pointcut that drives this advisor.
*/
Expand Down

0 comments on commit a63ccec

Please sign in to comment.