RestEasy Reactive returns different resource class/method than RestEasy classic
See original GitHub issueDescribe the bug
I have an Api class and a Resource class:
@Path("/v1/test")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Authenticate(value = false)
public interface Api {
String echoGet(@NotNull @QueryParam("message") String message);
}
@Singleton
@Provider
public class Resource implements Api {
@Override
public String echoGet(String message) {
return new message;
}
}
And I have a ContainerRequestFilter
@Singleton
@Provider
@Priority(Priorities.AUTHORIZATION)
public class AuthzContainerRequestFilter implements ContainerRequestFilter {
private final ResourceInfo resourceInfo;
@Inject
public AuthzContainerRequestFilter(ResourceInfo resourceInfo) {
this.resourceInfo = resourceInfo;
}
@Override
public void filter(ContainerRequestContext reqCtx) {
boolean requireAuthn;
Authenticate annotation = getAuthenticateAnnotation();
if (annotation != null) {
requireAuthn = annotation.value();
} else {
// the default is authenticate if no annotation
requireAuthn = true;
}
// code to implement authn
}
/**
* Get authentication annotation
*
* @return relevant authentication
*/
private Authenticate getAuthenticateAnnotation() {
Method resourceMethod = resourceInfo.getResourceMethod();
Authenticate authenticate = resourceMethod.getAnnotation(Authenticate.class);
if (authenticate != null) {
return authenticate;
}
Class<?> resourceClass = resourceInfo.getResourceClass();
return resourceClass.getAnnotation(Authenticate.class);
}
}
With RestEasy classic, ResourceInfo.getResourceClass()
returns my Api class. With RestEasy reactive, the result is my Resource class.
Expected behavior
I expect RestEasy Reactive to be a drop-in replacement for RestEasy classic, returning the Api class
Actual behavior
In RestEasy Reactive, resourceInfo.getResourceMethod() / resourceInfo.getResourceClass() return the Resource class.
How to Reproduce?
Use above classes.
Output of uname -a
or ver
No response
Output of java -version
No response
GraalVM version (if different from Java)
No response
Quarkus version or git rev
No response
Build tool (ie. output of mvnw --version
or gradlew --version
)
No response
Additional information
Over the years, and different jax-rs implementations have had different behaviors. Sometimes the implementation returns the resource class, sometimes the api class. I am not sure if the spec actually defines which should be returned.
I like the Api class/method to be returned. This way the Api class has annotations which are part of the interface contract.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (6 by maintainers)
Will do. Thanks for you feedback!
@knutwannheden yes, please open a new issue, as what you describe is different from what this issue is about.
Also FWIW, your analysis of the problem is most likely correct, so you if also want to send a PR (with the proper tests), you are more than welcome to do so 😃