Bird
0
0

Identify the error in this Micrometer counter registration code:

medium📝 Debug Q6 of 15
Spring Boot - Actuator
Identify the error in this Micrometer counter registration code:
Counter counter = Counter.builder("my.counter")
  .description("Counts events")
  .register(null);
ACounter.builder() requires a MeterRegistry parameter
BMissing call to increment() method
CPassing null to register causes NullPointerException
DDescription method is not valid for Counter
Step-by-Step Solution
Solution:
  1. Step 1: Analyze register() method parameter

    The register() method requires a non-null MeterRegistry instance.
  2. Step 2: Effect of passing null

    Passing null causes a NullPointerException at runtime.
  3. Final Answer:

    Passing null to register causes NullPointerException -> Option C
  4. Quick Check:

    Null MeterRegistry in register() = runtime error [OK]
Quick Trick: Always pass a valid MeterRegistry to register() [OK]
Common Mistakes:
  • Ignoring null MeterRegistry causes runtime failure
  • Thinking description() is invalid for Counter

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes