Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Blocking on resource is ignored if implementing an OpenAPI-generated interface #15940

Closed
famod opened this issue Mar 22, 2021 · 12 comments · Fixed by #15987
Closed

@Blocking on resource is ignored if implementing an OpenAPI-generated interface #15940

famod opened this issue Mar 22, 2021 · 12 comments · Fixed by #15987

Comments

@famod
Copy link
Member

famod commented Mar 22, 2021

Describe the bug

When generating interfaces from a OpenAPI defintion file via https://github.com/OpenAPITools/openapi-generator, all Jax-RS annotations are added to the interface so you don't have to repeat them in your actual resource that implements the interface.
If you decide that you need @Blocking, you have to put it in the interface to have it recognized.

Expected behavior

Since blocking or not is an implementation detail, I should not be forced to put this in the (generated) resource interface.

Actual behavior

As soon as a resource implements an interface that contains alls the Jax-RS annotations, @Blocking on the actually implemented methods (or the resource class) is ignored.

To Reproduce

quarkusio/quarkus-quickstarts@main...famod:issue-15940

Steps to reproduce the behavior:

  1. git clone https://github.com/famod/quarkus-quickstarts.git
  2. git switch issue-15940
  3. cd getting-started-reactive
  4. mvn verify (no error)
  5. remove @Blocking from ReactiveGreeting.greeting()
  6. mvn verify (error regarding IO thread)

Configuration

quarkus.datasource.db-kind=h2
quarkus.datasource.username=sa
quarkus.datasource.password=sa
quarkus.datasource.jdbc.url=jdbc:h2:mem:test_quarkus;DB_CLOSE_DELAY=-1

Environment (please complete the following information):

Output of uname -a or ver

Linux XXX 4.19.128-microsoft-standard #1 SMP Tue Jun 23 12:58:10 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9)
Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.24.0, JRE 11 Linux amd64-64-Bit Compressed References 20210120_910 (JIT enabled, AOT enabled)
OpenJ9   - 345e1b09e
OMR      - 741e94ea8
JCL      - 0a86953833 based on jdk-11.0.10+9)

(also happens with HotSpot)

GraalVM version (if different from Java)

Quarkus version or git rev

1.12.2

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.6.3

Additional context

@famod famod added the kind/bug Something isn't working label Mar 22, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Mar 22, 2021

@famod
Copy link
Member Author

famod commented Mar 22, 2021

I think this is more something for you @cescoffier or @geoand or @FroMage.

@gsmet gsmet added kind/enhancement New feature or request and removed kind/bug Something isn't working labels Mar 23, 2021
@geoand
Copy link
Contributor

geoand commented Mar 23, 2021

We could certainly also consult the implementation class (it makes perfect sense to do so), however this seems to be a general issue - we only seem to consult the annotation from the interface.

@FroMage do you remember if the spec mentions something specific about annotations on the interface vs the impl class?

@FroMage
Copy link
Member

FroMage commented Mar 23, 2021

https://quarkus.io/specs/jaxrs/2.1/index.html#annotationinheritance says:

If a subclass or implementation method has any JAX-RS annotations then all of the annotations on the superclass or interface method are ignored.

So we should look at whatever source has any JAX-RS annotation. Also note that superclass is favoured over superinterfaces.

@geoand
Copy link
Contributor

geoand commented Mar 23, 2021

Very interesting, thanks!

@famod
Copy link
Member Author

famod commented Mar 23, 2021

So we should look at whatever source has any JAX-RS annotation

Which wouldn't solve my problem, would it?

I do understand the spec part, but io.smallrye.common.annotation.Blocking isn't really a JAX-RS annotation, IMO.

@geoand
Copy link
Contributor

geoand commented Mar 23, 2021

It isn't true, but I am not entirely convinced we should differentiate the standard behavior here.

@famod
Copy link
Member Author

famod commented Mar 23, 2021

Right now, this issue is not a big deal for my current project. We just add it to a mustache template we have to override anyway and everything is blocking (which suites our current needs).

But as soon as we want to have certain calls non-blocking, things will become verbose:
We would either need to introduce a vendor extension to control when to generate @Blocking, which pollutes the OpenAPI file with internals.
Or we would need to use that Infrastructure-something class (don't have the code in front of me right now) to make all respective Mutiny calls blocking, one by one.

@geoand
Copy link
Contributor

geoand commented Mar 24, 2021 via email

@geoand
Copy link
Contributor

geoand commented Mar 24, 2021

#15987 should take care of it

geoand added a commit that referenced this issue Mar 26, 2021
Allow using @Blocking on implementation in addition to interface for JAX-RS Resources
@quarkus-bot quarkus-bot bot added this to the 1.14 - main milestone Mar 26, 2021
@famod
Copy link
Member Author

famod commented Mar 26, 2021

@geoand Thanks a lot for this rapid turnaround!

@geoand
Copy link
Contributor

geoand commented Mar 26, 2021

YW!

@gsmet gsmet modified the milestones: 1.14 - main, 1.13.1.Final Apr 3, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue Apr 3, 2021
juazugas pushed a commit to juazugas/quarkus that referenced this issue Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants