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

Micrometer logs java.lang.NullPointerException with Scheduled tasks #4507

Closed
cloudbackenddev opened this issue Dec 21, 2023 · 1 comment
Closed
Labels
for: external-project For an external project and not something we can fix invalid An issue that we don't feel is valid

Comments

@cloudbackenddev
Copy link

Describe the bug
Logs are flooded with Micrometer null pointer errors when used with Scheduled tasks in spring boot.Refer full trace of logs under additional context section. Have given a simple example of how to replicate the issue
at java.base/java.util.Objects.requireNonNull(Objects.java:208) ~[na:na]
at io.micrometer.common.ImmutableKeyValue.(ImmutableKeyValue.java:38) ~[micrometer-commons-1.12.0.jar:1.12.0]

Environment

  • Spring Boot 3.2.0
  • Micrometer version [e.g. 1.12.0]
  • OS: Ubuntu
  • Java version: [e.g. output of java -version]
    openjdk 17.0.6 2023-01-17 LTS
    OpenJDK Runtime Environment Corretto-17.0.6.10.1 (build 17.0.6+10-LTS)
    OpenJDK 64-Bit Server VM Corretto-17.0.6.10.1 (build 17.0.6+10-LTS, mixed mode, sharing)

To Reproduce
How to reproduce the bug:
Refer this example app -> https://github.com/cloudbackenddev/demoapp

Expected behavior
No nullpointer errors are expected

Additional context
Full trace of the errot
java.lang.NullPointerException: null
at java.base/java.util.Objects.requireNonNull(Objects.java:208) ~[na:na]
at io.micrometer.common.ImmutableKeyValue.(ImmutableKeyValue.java:38) ~[micrometer-commons-1.12.0.jar:1.12.0]
at io.micrometer.common.KeyValue.of(KeyValue.java:48) ~[micrometer-commons-1.12.0.jar:1.12.0]
at io.micrometer.common.KeyValue.of(KeyValue.java:58) ~[micrometer-commons-1.12.0.jar:1.12.0]
at org.springframework.scheduling.support.DefaultScheduledTaskObservationConvention.codeNamespace(DefaultScheduledTaskObservationConvention.java:64) ~[spring-context-6.1.1.jar:6.1.1]
at org.springframework.scheduling.support.DefaultScheduledTaskObservationConvention.getLowCardinalityKeyValues(DefaultScheduledTaskObservationConvention.java:56) ~[spring-context-6.1.1.jar:6.1.1]
at org.springframework.scheduling.support.DefaultScheduledTaskObservationConvention.getLowCardinalityKeyValues(DefaultScheduledTaskObservationConvention.java:31) ~[spring-context-6.1.1.jar:6.1.1]
at io.micrometer.observation.SimpleObservation.start(SimpleObservation.java:152) ~[micrometer-observation-1.12.0.jar:1.12.0]
at io.micrometer.observation.Observation.observe(Observation.java:497) ~[micrometer-observation-1.12.0.jar:1.12.0]
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:124) ~[spring-context-6.1.1.jar:6.1.1]
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-6.1.1.jar:6.1.1]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[na:na]
at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[na:na]
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]

@marcingrzejszczak
Copy link
Contributor

@bclozel I think that DefaultScheduledTaskObservationConvention in methods like this requires a null check. I'm closing this in favour of spring-projects/spring-framework#31918

@marcingrzejszczak marcingrzejszczak closed this as not planned Won't fix, can't repro, duplicate, stale Dec 28, 2023
@marcingrzejszczak marcingrzejszczak added invalid An issue that we don't feel is valid and removed waiting-for-triage labels Dec 28, 2023
@jonatan-ivanov jonatan-ivanov added the for: external-project For an external project and not something we can fix label Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants