Is the method @PreDestroy
of a prototype bean called when the bean is garbage collected ?
Asked
Active
Viewed 132 times
1

rptmat57
- 3,643
- 1
- 27
- 38

La Carbonell
- 1,976
- 5
- 22
- 52
-
1No it isn't going to be called. With a prototype scoped bean you are responsible for the cleanup – M. Deinum Mar 28 '17 at 11:44
1 Answers
2
No, it is not called when the bean is garbage collected but for the bean to be garbage collected it has to be dereferenced first, which would mean it would have to be destroyed and @PreDestroy
be called.
So the method won't be called directly but it has to have been called before being garbage collected

rptmat57
- 3,643
- 1
- 27
- 38