Bird
0
0

Given this Kafka Streams snippet, what will happen if a record causes a NullPointerException inside the mapValues function?

medium📝 Predict Output Q4 of 15
Kafka - Advanced Stream Processing
Given this Kafka Streams snippet, what will happen if a record causes a NullPointerException inside the mapValues function?
stream.mapValues(value -> {
  if(value == null) throw new NullPointerException();
  return value.toUpperCase();
});
AThe record will be sent to a dead-letter topic automatically
BThe stream processing will stop with an exception
CThe record will be skipped and processing continues
DThe stream will retry processing the record indefinitely
Step-by-Step Solution
Solution:
  1. Step 1: Analyze exception handling in mapValues

    Without explicit try-catch, exceptions thrown inside mapValues stop the stream.
  2. Step 2: Understand default Kafka Streams behavior on exceptions

    Kafka Streams does not skip or retry records automatically without error handlers.
  3. Final Answer:

    The stream processing will stop with an exception -> Option B
  4. Quick Check:

    Unhandled exception = Stream stops [OK]
Quick Trick: Unhandled exceptions stop Kafka Streams processing [OK]
Common Mistakes:
  • Assuming automatic skipping of bad records
  • Thinking dead-letter topics are automatic
  • Believing infinite retries happen by default

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes