This is my first message posted here after I finally succeeded in subscribing to Hibernate dev mail list.
As well known, we utilized the following 'lazy initialization' pattern extensively in our codebase to save memory: if ( activeFactoryNames == null ) { activeFactoryNames = new ArrayList<>(); } However, even since JDK7, ArrayList has gone through refactoring to keep from allocating memory for 10 elements in advance, if the instance was created by default constructor and the allocation of memory is only done when some element is really added in future. Namely, ArrayList has the lazy initialization feature built-in. E.g., see https://stackoverflow.com/questions/33688753/jdk-api-documentation-is-incorrect-for-arraylist-constructor-is-that-a-bug for details. You can also browse the source code of ArrayList to confirm. [image: Screen Shot 2020-08-18 at 4.06.58 PM.png] Needless to say, the lazy initialization pattern has serious NPE issue if it is not coded carefully (which is tedious and error-prone per se). As an active Hibernate v6 contributor, I am troubled by such NPE issue again and again. Is it a good timing to get rid of the above lazy initialization pattern for now? Hopefully my message is good food for thought. No finger pointing. Just curious.
_______________________________________________ hibernate-dev mailing list -- hibernate-dev@lists.jboss.org To unsubscribe send an email to hibernate-dev-le...@lists.jboss.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s