Closed
Description
Describe the bug
In a minimal example, use-management-port is generating NPEs when accessing v3/api-docs.
java.lang.NullPointerException: null
at org.springdoc.core.ActuatorProvider.getApplicationPort(ActuatorProvider.java:185) ~[springdoc-openapi-common-1.5.2.jar:1.5.2]
at org.springdoc.api.AbstractOpenApiResource.getActuatorURI(AbstractOpenApiResource.java:1061) ~[springdoc-openapi-common-1.5.2.jar:1.5.2]
at org.springdoc.webmvc.api.OpenApiActuatorResource.getServerUrl(OpenApiActuatorResource.java:152) ~[springdoc-openapi-webmvc-core-1.5.2.jar:1.5.2]
at org.springdoc.webmvc.api.OpenApiResource.calculateServerUrl(OpenApiResource.java:295) ~[springdoc-openapi-webmvc-core-1.5.2.jar:1.5.2]
at org.springdoc.webmvc.api.OpenApiResource.openapiJson(OpenApiResource.java:171) ~[springdoc-openapi-webmvc-core-1.5.2.jar:1.5.2]
at org.springdoc.webmvc.api.OpenApiActuatorResource.openapiJson(OpenApiActuatorResource.java:131) ~[springdoc-openapi-webmvc-core-1.5.2.jar:1.5.2]
This appears to be because the ActuatorProvider is trying to access a port from a null applicationWebServer
. However the previous call's if statement in AbstractOpenApiResource might also be taking the wrong path. It could also be that my example is too minimal and I am missing some configuration.
To Reproduce
- Steps to reproduce the behavior:
- Created a simple project with one api endpoint, no groupings.
- Add Springdoc, v3/api-docs returns valid apis.
- Enable use-management-port, and set a management port.
- actuator/openapi produces NPE
What version of spring-boot you are using?
- 2.4.1
What modules and versions of springdoc-openapi are you using? - 1.5.2
Expected behavior
- The same response I get when accessing without using the management port.