Bird
0
0

What will happen if you try to register a Gauge metric with a null value supplier in Micrometer?

medium📝 component behavior Q5 of 15
Spring Boot - Actuator
What will happen if you try to register a Gauge metric with a null value supplier in Micrometer?
ARegisters successfully with zero value
BThrows IllegalArgumentException at runtime
CIgnores the metric silently
DThrows compile-time error
Step-by-Step Solution
Solution:
  1. Step 1: Understand Gauge metric requirements

    Gauge requires a non-null value supplier to provide metric values.
  2. Step 2: Effect of null supplier

    Passing null causes an IllegalArgumentException at registration because Micrometer validates the supplier is not null.
  3. Final Answer:

    Throws IllegalArgumentException at runtime -> Option B
  4. Quick Check:

    Null supplier for Gauge = IllegalArgumentException [OK]
Quick Trick: Gauge needs a valid supplier, null causes runtime error [OK]
Common Mistakes:
  • Assuming null supplier defaults to zero
  • Expecting compile-time errors for null suppliers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes