dimanche 14 avril 2019

Can java reflection break Spring Singleton object

As we all aware that reflection, cloning and serialization, all can break Singleton and there are various ways to prevent them. Such as In case of serialization we can make use of readResolve(), enums can be used to prevent reflection to break singleton.

Now coming to my question as we all know that default scope of a Spring bean is Singleton, so do Spring singleton cannot be broken by reflection or serialization. Do Spring provide some feature.

Please let me know if you need some more information.





Aucun commentaire:

Enregistrer un commentaire