Skip to content

Commit

Permalink
Only check filters once for calls to getResourceMethod
Browse files Browse the repository at this point in the history
Before, for each resource method, no matter if rest-client or rest-server, each filter was checked if it called ResourceInfo#getResourceMethod. This can however be cached, since the set of filters does not change.

(cherry picked from commit 9a3fd38)
  • Loading branch information
Postremus authored and gsmet committed Feb 18, 2025
1 parent 200e050 commit 5f3abf6
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,8 @@ public void setupEndpoints(ApplicationIndexBuildItem applicationIndexBuildItem,
classLevelExceptionMappers.isPresent() ? classLevelExceptionMappers.get().getMappers()
: Collections.emptyMap())
.setResourceMethodCallback(new Consumer<>() {
Boolean filtersAccessResourceMethod;

@Override
public void accept(EndpointIndexer.ResourceMethodCallbackEntry entry) {
MethodInfo method = entry.getMethodInfo();
Expand All @@ -588,6 +590,11 @@ public void accept(EndpointIndexer.ResourceMethodCallbackEntry entry) {
.build());
}

if (filtersAccessResourceMethod == null) {
filtersAccessResourceMethod = filtersAccessResourceMethod(
resourceInterceptorsBuildItem.getResourceInterceptors());
}

boolean paramsRequireReflection = false;
for (short i = 0; i < method.parametersCount(); i++) {
Type parameterType = method.parameterType(i);
Expand All @@ -611,12 +618,12 @@ public void accept(EndpointIndexer.ResourceMethodCallbackEntry entry) {
}
}

if (paramsRequireReflection ||
if (filtersAccessResourceMethod ||
paramsRequireReflection ||
MULTI.toString().equals(entry.getResourceMethod().getSimpleReturnType()) ||
REST_MULTI.toString().equals(entry.getResourceMethod().getSimpleReturnType()) ||
PUBLISHER.toString().equals(entry.getResourceMethod().getSimpleReturnType()) ||
LEGACY_PUBLISHER.toString().equals(entry.getResourceMethod().getSimpleReturnType()) ||
filtersAccessResourceMethod(resourceInterceptorsBuildItem.getResourceInterceptors()) ||
entry.additionalRegisterClassForReflectionCheck()) {
minimallyRegisterResourceClassForReflection(entry, reflectiveClassBuildItemBuildProducer);
}
Expand Down

0 comments on commit 5f3abf6

Please sign in to comment.