Happy new year to you and all Liferay developer! :-)
We have tested the liferay-faces-3.0.1-legacy-ga2 and i am sorry to say that: The error still exists.
After another session with debugging and heap dumping we recognized that after several requests the BridgeRequestScopeCache caches BridgeRequestScopeLiferayImpl objects. If i have understood you correctly, you said that these objects should be removed at the end of a request.
To check that, i make heap dump (with jvisualvm) after a clean start of the app server und after a single request of a portal page with jsf portlets. The first dump contains no BridgeRequestScopeLiferayImpl objects (expected), but the second one does (not expected). In the second dump i can see the references to the BridgeRequestScopeLiferayImpl object that prevent it from being removed from heap. These references are internal references e.g. BridgeRequestScopeCompatImpl$FacesContextAttribute or BridgeRequestScopeImpl$RequestAttribute
I wondered why so i took a deeper look into the implementation:
In BridgeRequestScopeCompatImpl.saveJSF2FacesContextAttributes() you store all attributes from facesContext into a List. This list contains objects of BridgeRequestScopeCompatImpl$FacesContextAttribute and contain references to attributes of the facesContext. Because these objects are instances of a internal class they also hold a reference to its parent.
In BridgeRequestScopeCompatImpl.restoreJSF2FacesContextAttributes() you restore all attributes but the objects are not cleared explicitly. In my opinion this is the reason why the BridgeRequestScopeLiferayImpl objects cannot be removed from the heap.
An easy fix in BridgeRequestScopeCompatImpl.restoreJSF2FacesContextAttributes() should solve this:
1
2[...]
3if (restoredFacesContextAttibutes) {
4 savedFacesContextAttributes.clear();
5 logger.debug("Restored FacesContext attributes");
6}
7else {
8 logger.debug("Did not restore any FacesContext attributes");
9}
10[...]
We tested this small fix successfully. Now no BridgeRequestScopeLiferayImpl objects stay in the heap after a request anymore. The cache is empty after a request.
So what do you think?
Firmi prego dentro per inbandierare questo come inadeguato.