Spring destroy-method and half of the entered objects

In spring, I often use the init-method and destroy-method attributes on beans. I am interested in the contract of these methods. The init-method attribute is apparently called a post-construction even after all properties have been set. My question is that the destroy method has the same contract. If the setter throws for any reason, and the object does not have all its properties, spring will not call the init method, but I can not find the documentation for spring calling the destroy method in this situation.

If he explicitly checks that the null value should be in place, I'm curious what others are doing in this situation.

+3
source share
2 answers

, , , , init, destroy.

, . - , , , . ​​ . , . .

, , null , .

+2

Spring AbstractAutowireCapableBeanFactory.doCreateBean() ( Spring 3 M4, Spring 2.5). , , - bean , , ( ) . , - bean , destroy .

+2

Source: https://habr.com/ru/post/1718188/


All Articles