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

spring-modulith-observability breaks RestControllers implementing an Interface #653

Open
gmuecke opened this issue Jun 7, 2024 · 1 comment

Comments

@gmuecke
Copy link

gmuecke commented Jun 7, 2024

When the spring-modulith-observability dependency is present, RestControllers that implement any interface are no longer serving their endpoints or apear in the OpenAPI documentation (Swagger).

This is not limited to interfaces with Rest Annotations (like @GetMapping), or OpenAPI Annotations, but also to interfaces that are not related to the REST API, including empty marker interfaces.

The expected behavior is, that the spring-modulith-observability doesn't have an effect on the availability of RestControllers implementing an interface.

Reproducer https://github.com/gmuecke/spring-modulith-observability-reproducer

Spring Modulith: 1.2.0, 1.1.5
Spring Boot: 3.3.0, 3.2.6
JDK 21

@tobHai
Copy link
Contributor

tobHai commented Jun 8, 2024

In the reproducer Module1Controller is not implementing an interface, Module2Controller and Module3Controller however are implementing an interface.

For the Module1Controller bean the ModuleTracingBeanPostProcessor.postProcessAfterInitialization returns a Spring CGLIB Proxy, which is then processed by the other BeanPostProcessor instances.
For the controllerModule2Controller and Module3Controller beans a JdkDynamicAOPProxy instance is returned.

Unfortunately I'm not sure whether this behavior really causes the outlined issue, but maybe this first analysis helps you @odrotbohm.

Edit:
I assume this is a general Spring AOP limitation which is used by spring-modulith-observability under the hood.
The RequestMapping docs point out (in the last note) that mapping annotations should be added on the interface rather than the implementing controller class when AOP is used.
When annotating the interfaces rather than the controller classes in your reproducer they are picked up again properly by SpringDocs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants