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

NullPointer during Rest client creation when micrometer is disabled #25099

Closed
danielmaison opened this issue Apr 22, 2022 · 3 comments · Fixed by #25169
Closed

NullPointer during Rest client creation when micrometer is disabled #25099

danielmaison opened this issue Apr 22, 2022 · 3 comments · Fixed by #25169
Assignees
Labels
Milestone

Comments

@danielmaison
Copy link

Describe the bug

NullPointer is thrown if micrometer is included but disabled when RestClient is created.

Expected behavior

Application to work as usual, but without metrics reported

Actual behavior

Nullpointer during RestClient creation

Caused by: java.lang.NullPointerException
    at io.quarkus.micrometer.runtime.binder.RestClientMetricsListener.prepClientMetrics(RestClientMetricsListener.java:50)
    at io.quarkus.micrometer.runtime.binder.RestClientMetricsListener.onNewClient(RestClientMetricsListener.java:38)
    at io.quarkus.restclient.runtime.QuarkusRestClientBuilder.lambda$build$0(QuarkusRestClientBuilder.java:236)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
    at io.quarkus.restclient.runtime.QuarkusRestClientBuilder.build(QuarkusRestClientBuilder.java:236)
    at io.quarkus.restclient.runtime.RestClientBase.create(RestClientBase.java:72)

How to Reproduce?

Reproducing project:
https://github.com/danielmaison/quarkus-micrometer-bug

Simple Quarkus project generated with Quarkus 2.8.1.Final and extensions:

  • quarkus-resteasy (classic)
  • quarkus-resteasy-jsonb
  • quarkus-rest-client-jsonb
  • quarkus-micrometer-registry-prometheus

Changes made to sample code

  1. application.properties - disabled micrometer
  2. Added Rest client interface with empty get method
  3. In Server rest resource, inject rest client

Reproduce by: Calling server resource (e.g. via test)

Output of uname -a or ver

Linux Desktop 5.10.60.1-microsoft-standard-WSL2 #1 SMP Wed Aug 25 23:20:18 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk 11.0.14.1 2022-02-08 OpenJDK Runtime Environment (build 11.0.14.1+1-Ubuntu-0ubuntu1.20.04) OpenJDK 64-Bit Server VM (build 11.0.14.1+1-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)

GraalVM version (if different from Java)

N/A

Quarkus version or git rev

2.8.1.Final

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

Apache Maven 3.8.4

Additional information

No response

@danielmaison danielmaison added the kind/bug Something isn't working label Apr 22, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Apr 22, 2022

/cc @ebullient, @michalszynkiewicz

@geoand geoand self-assigned this Apr 26, 2022
geoand added a commit to geoand/quarkus that referenced this issue Apr 26, 2022
ebullient added a commit that referenced this issue Apr 26, 2022
Prevent NPE when micrometer is disabled
@quarkus-bot quarkus-bot bot added this to the 2.9 - main milestone Apr 26, 2022
@danielmaison
Copy link
Author

Thank you for your quick response <3

@geoand
Copy link
Contributor

geoand commented Apr 26, 2022

Thanks for the reproducer, it was most helpful :)

holly-cummins pushed a commit to holly-cummins/quarkus that referenced this issue Apr 27, 2022
@gsmet gsmet modified the milestones: 2.9.0.CR1, 2.8.3.Final May 5, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue May 5, 2022
@gsmet gsmet modified the milestones: 2.8.3.Final, 2.7.6.Final May 18, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants