The method com.vaadin.ui.UI.getCurrent() returns a valid UI instance, but calling getSession() on that UI instance returns null, while initiating the class.
VaadinSession.getCurrent() returns the valid session.
We might have to document this as a known limitation. The problem here is that the legacy UI instance won't be attached and inited until during the next round trip. If we manually attach it earlier, I suspect there will be problems when the regular code path tries to attach it again.
I just found out that this issue can cause NPE when calling "Page.getCurrent().getLocation()", since getLocation(..) is calling uI.getSession().getConfiguration().
@stefanuebe commented on Thu Aug 30 2018
The method com.vaadin.ui.UI.getCurrent() returns a valid UI instance, but calling getSession() on that UI instance returns null, while initiating the class.
VaadinSession.getCurrent() returns the valid session.
@Legioth commented on Thu Aug 30 2018
We might have to document this as a known limitation. The problem here is that the legacy
UI
instance won't be attached and inited until during the next round trip. If we manually attach it earlier, I suspect there will be problems when the regular code path tries to attach it again.