Skip to content

Commit

Permalink
Merge pull request #46284 from Postremus/issues/45631-filter-resource…
Browse files Browse the repository at this point in the history
…-getmethod-slow

Only check filters once for calls to getResourceMethod
  • Loading branch information
geoand authored Feb 15, 2025
2 parents c190b10 + 9a3fd38 commit f3068af
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 f3068af

Please sign in to comment.