A bean stores per-request user data in a field, but it is singleton scoped. What is the biggest risk?
Practice this question from Quiz: Spring Core, with options and an explanation.
Question
A bean stores per-request user data in a field, but it is singleton scoped. What is the biggest risk?
Option A — Correct answer
State can leak across requests or threads
Singleton beans are shared by default.
Option B
The bean cannot be autowired
Option C
The JVM cannot compile annotations
Option D
The class becomes abstract automatically
Explanation
Singleton beans are shared, so mutable request-specific state can leak between users or threads.