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

NullPointerException in MicrometerRecorder.registerMetrics #20350

Closed
rolfborst opened this issue Sep 23, 2021 · 5 comments · Fixed by #20368
Closed

NullPointerException in MicrometerRecorder.registerMetrics #20350

rolfborst opened this issue Sep 23, 2021 · 5 comments · Fixed by #20368
Labels
area/metrics kind/bug Something isn't working
Milestone

Comments

@rolfborst
Copy link

rolfborst commented Sep 23, 2021

Describe the bug

Hello Quarkus-Team,

great work. I'm currently moving a project from tomee to quarkus. This is a example project for my students in "database technology". So I have used a lot of your extensions for jpa, mongodb, neo4j, cassandra, ... All worked absolutly fine. In a last step I want to introduce the extension "quarkus-micrometer-registry-prometheus" to demonstrate the use of prometheus as a time series database. When I add this extension, the project doesn't start any more. The exception is:

2021-09-23 08:55:32,209 ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application (with profile dev): java.lang.NullPointerException
	at io.quarkus.micrometer.runtime.MicrometerRecorder.registerMetrics(MicrometerRecorder.java:169)
	at io.quarkus.deployment.steps.MicrometerProcessor$configureRegistry-2125003310.deploy_0(MicrometerProcessor$configureRegistry-2125003310.zig:123)
	at io.quarkus.deployment.steps.MicrometerProcessor$configureRegistry-2125003310.deploy(MicrometerProcessor$configureRegistry-2125003310.zig:40)
	at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:1189)
	at io.quarkus.runtime.Application.start(Application.java:101)
	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:101)

It seems to me, that one of my lot of extension does not work correctly and so corrupt the complete system.

Is it possible, that you do a null check in the registerMetrics method (the parameter consumer is called with null)?

    public void registerMetrics(Consumer<MetricsFactory> consumer) {
        consumer.accept(factory);
    }

I do a greater google search but it seems that no other people has my problem ;-)

I have tried to deactivate all of the metrics in the application.properties to find the "corrupt" extension but no of these deactivations have an effect to my NullPointerProblem.

quarkus.micrometer.binder.jvm=false
quarkus.micrometer.binder.system=false
quarkus.micrometer.binder-enabled-default=false
quarkus.micrometer.registry-enabled-default=false
quarkus.scheduler.metrics.enabled=false
quarkus.datasource.jdbc.enable-metrics=false
quarkus.datasource.metrics.enabled=false
quarkus.hibernate-orm.statistics=false
quarkus.hibernate-orm.metrics.enabled=false
quarkus.neo4j.pool.metrics.enabled=false
quarkus.log.metrics.enabled=false
quarkus.smallrye-graphql.metrics.enabled=false
quarkus.grpc.metrics.enabled=false

Only when I deactivate all with "quarkus.micrometer.enabled=true" there is no NullPointerException any more. But then I also have no metrics ;-)

For me, this is not a serious problem, because that is a project for students, but I want to report the problem so that you can think about a null check at this point.

Bye
Rolf

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.1.0.Final

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

No response

Additional information

No response

@rolfborst rolfborst added the kind/bug Something isn't working label Sep 23, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Sep 23, 2021

/cc @ebullient, @jmartisk, @kenfinnigan

@geoand
Copy link
Contributor

geoand commented Sep 23, 2021

It looks like neo4j is the one responsible for the null consumer: https://github.com/quarkusio/quarkus/blob/2.3.0.CR1/extensions/neo4j/runtime/src/main/java/io/quarkus/neo4j/runtime/Neo4jDriverRecorder.java#L79

I'll leave it up to @ebullient to decide whether null should be allowed (and therefore guarded against) or not.

@rolfborst
Copy link
Author

Wow, absolutly great work how fast you find the problem :-)

When I activate the neo4j-metrics all works fine:

quarkus.neo4j.pool.metrics.enabled=true

When I set it to false or leave it unset, I get the NullPointerException

@ebullient
Copy link
Member

I should absolutely be checking for null because it can apparently happen, though it would be kinder for neo4j not to register the supplier at all unless metrics are turned on. I'll try to fix both. Thanks for looking Georgios.. you beat me to it.

@geoand
Copy link
Contributor

geoand commented Sep 23, 2021

👍🏼

@quarkus-bot quarkus-bot bot added this to the 2.4 - main milestone Sep 24, 2021
@geoand geoand modified the milestones: 2.4 - main, 2.3.0.Final Sep 28, 2021
@gsmet gsmet modified the milestones: 2.3.0.Final, 2.2.4.Final Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/metrics kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants