question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RestEasy Reactive returns different resource class/method than RestEasy classic

See original GitHub issue

Describe 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:open
  • Created 2 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
knutwannhedencommented, Jul 4, 2022

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 😃

Will do. Thanks for you feedback!

0reactions
geoandcommented, Jul 4, 2022

@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 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

RESTEasy Classic - Quarkus
You can return reactive types to handle asynchronous processing. Quarkus recommends the usage of Mutiny to write reactive and asynchronous code. To integrate ......
Read more >
RESTEasy JAX-RS - JBoss.org
RESTEasy is installed and configured in different ways depending on which environment you are running in. If you are running in WildFly, RESTEasy...
Read more >
Developing Web Services Applications Red Hat JBoss ...
Web services provide a standard means of interoperating among different software applications ... RESTEasy will then automatically discover those resources.
Read more >
ServerExceptionMapper doesn't handle all errors of the ...
And then we get into the class method, where the response is ... I watched the article https://quarkus.io/guides/resteasy-reactive.
Read more >
Quarkus-For-Spring-Developers-Red-Hat - Processos de ...
Like RESTEasy Classic, developers can mix and match blocking and reactive program- ming styles within the same resource class. Benchmarks have shown that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found