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

Minimal project with use-management-port set causes NPE on api-docs endpoint #996

Closed
dominic-jones opened this issue Dec 21, 2020 · 1 comment · Fixed by #1002
Closed
Labels
bug Something isn't working

Comments

@dominic-jones
Copy link

dominic-jones commented Dec 21, 2020

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.
@bnasslahsen
Copy link
Contributor

@dominic-jones,

Unfortunately, this issue is not reproducible.
Please add or refer to a sample minimal project in GITHUB, that reproduces this issue.

This ticket is now closed. And can be reopened if a reproducible project is provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants