Apart from the comment of happymellon (blaming Spring for doing things behind your back), it happens that a factory , building objects for you , will have a “bug” and retain a reference to them for whatever reason.
That is sometimes tricky to figure out.
Nothing Java can be blamed for, as these kind of tricks can happen in any language.
([newbie at C but] I suppose in C, the consumer of the object can force its deallocation, which may lead to other nasty side effect]
They expected not to have to deal with memory at all, I presume ;)
[to go a bit off topic, the debugging of those issues is reasonably tool-assisted in Java, whereas I honestly don’t know how to solve them in, let’s say, Javascript/TS).