All jobs / Backend developer

Backend developer interview question · 3–5 years

A Spring service bean keeps the current user in a field so its helper methods can read it. Under load, users start seeing each other’s data.

What is wrong, and what is the fix?

The strongest answer

Beans are singletons by default — one instance serves every concurrent request — so a mutable field is shared state; keep the bean stateless and pass the request data in as parameters

Why it works

Exactly — one instance, many threads. Statelessness is the fix; scope tricks only work around a design mistake.

What a good answer covers

Answers that fall short

Who gets asked this

More Backend developer questions