Skip to content

Commit 2fdb9c5

Browse files
authored
Merge pull request #45219 from geoand/rr-optimization
Get rid of unnecessary reflective calls at RESTEasy Reactive startup
2 parents 66b2630 + ab710d6 commit 2fdb9c5

File tree

2 files changed

+2
-43
lines changed

2 files changed

+2
-43
lines changed

independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/startup/RuntimeResourceDeployment.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717
import java.util.Arrays;
1818
import java.util.Collections;
1919
import java.util.HashMap;
20-
import java.util.HashSet;
2120
import java.util.List;
2221
import java.util.Map;
2322
import java.util.Optional;
24-
import java.util.Set;
2523
import java.util.concurrent.Executor;
2624
import java.util.function.Supplier;
2725

@@ -177,19 +175,8 @@ public RuntimeResource buildResourceMethod(ResourceClass clazz,
177175
}
178176
}
179177

180-
Annotation[] resourceClassAnnotations = resourceClass.getAnnotations();
181-
Set<String> classAnnotationNames;
182-
if (resourceClassAnnotations.length == 0) {
183-
classAnnotationNames = Collections.emptySet();
184-
} else {
185-
classAnnotationNames = new HashSet<>(resourceClassAnnotations.length);
186-
for (Annotation annotation : resourceClassAnnotations) {
187-
classAnnotationNames.add(annotation.annotationType().getName());
188-
}
189-
}
190-
191178
ResteasyReactiveResourceInfo lazyMethod = new ResteasyReactiveResourceInfo(method.getName(), resourceClass,
192-
parameterDeclaredUnresolvedTypes, classAnnotationNames, method.getMethodAnnotationNames(),
179+
parameterDeclaredUnresolvedTypes,
193180
!defaultBlocking && !method.isBlocking(), method.getActualDeclaringClassName());
194181

195182
RuntimeInterceptorDeployment.MethodInterceptorContext interceptorDeployment = runtimeInterceptorDeployment

independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/spi/ResteasyReactiveResourceInfo.java

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.lang.annotation.Annotation;
44
import java.lang.reflect.Method;
55
import java.lang.reflect.Type;
6-
import java.util.Set;
76

87
import jakarta.ws.rs.container.ResourceInfo;
98

@@ -20,8 +19,6 @@ public class ResteasyReactiveResourceInfo implements ResourceInfo {
2019
private final String name;
2120
private final Class<?> declaringClass;
2221
private final Class[] parameterTypes;
23-
private final Set<String> classAnnotationNames;
24-
private final Set<String> methodAnnotationNames;
2522
/**
2623
* If it's non-blocking method within the runtime that won't always default to blocking
2724
*/
@@ -30,27 +27,17 @@ public class ResteasyReactiveResourceInfo implements ResourceInfo {
3027
* This class name will only differ from {@link this#declaringClass} name when the {@link this#method} was inherited.
3128
*/
3229
private final String actualDeclaringClassName;
33-
private volatile Annotation[] classAnnotations;
3430
private volatile Method method;
3531
private volatile Annotation[] annotations;
3632
private volatile Type returnType;
3733
private volatile String methodId;
3834

39-
@Deprecated
40-
public ResteasyReactiveResourceInfo(String name, Class<?> declaringClass, Class[] parameterTypes,
41-
Set<String> classAnnotationNames, Set<String> methodAnnotationNames, boolean isNonBlocking) {
42-
this(name, declaringClass, parameterTypes, classAnnotationNames, methodAnnotationNames, isNonBlocking,
43-
declaringClass.getName());
44-
}
45-
4635
public ResteasyReactiveResourceInfo(String name, Class<?> declaringClass, Class[] parameterTypes,
47-
Set<String> classAnnotationNames, Set<String> methodAnnotationNames, boolean isNonBlocking,
36+
boolean isNonBlocking,
4837
String actualDeclaringClassName) {
4938
this.name = name;
5039
this.declaringClass = declaringClass;
5140
this.parameterTypes = parameterTypes;
52-
this.classAnnotationNames = classAnnotationNames;
53-
this.methodAnnotationNames = methodAnnotationNames;
5441
this.isNonBlocking = isNonBlocking;
5542
this.actualDeclaringClassName = actualDeclaringClassName;
5643
}
@@ -63,14 +50,6 @@ public Class[] getParameterTypes() {
6350
return parameterTypes;
6451
}
6552

66-
public Set<String> getClassAnnotationNames() {
67-
return classAnnotationNames;
68-
}
69-
70-
public Set<String> getMethodAnnotationNames() {
71-
return methodAnnotationNames;
72-
}
73-
7453
public Method getMethod() {
7554
if (method == null) {
7655
synchronized (this) {
@@ -89,13 +68,6 @@ public Method getMethod() {
8968
return method;
9069
}
9170

92-
public Annotation[] getClassAnnotations() {
93-
if (classAnnotations == null) {
94-
classAnnotations = declaringClass.getAnnotations();
95-
}
96-
return classAnnotations;
97-
}
98-
9971
public Annotation[] getAnnotations() {
10072
if (annotations == null) {
10173
getMethod();

0 commit comments

Comments
 (0)