Fix for #23735 in 2.3.x.

Given that 2.3.5 has not been released yet, I am flagging this one as a task as a follow-up of #22852.

Comment From: snicoll

HibernateMetricsAutoConfiguration takes a map of String to EMF beans and register metrics. This happening with parallel initialisation means that a deadlock can be happening.

I've moved locally that code to SmartInitializingSingleton#afterSingletonsInstantiated and that did the trick for me but I'd like to confirm that this is the right approach before changing anything in 2.3.x.

Comment From: snicoll

I've reproduced the problem in our smoke test for JPA.