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.
  • Loading branch information
Postremus committed Feb 15, 2025
1 parent 046dc99 commit 9a3fd38
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,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 @@ -589,6 +591,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 @@ -612,12 +619,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 9a3fd38

Please sign in to comment.