Search code examples
jsf-2memory-leakscomposite-componentomnifacesunmappedresourcehandler

OmniFaces UnmappedResourceHandler seems to leak resources when composite components are used


It seems UnmappedResourceHandler is loading composite components xhtml files within the resources folder. The result seems a gradually increasing memory leak.

The leak can be found within FaceletViewHandlingStrategy.metadataCache. It relies on a hashmap and when above handler is used UnmappedResources are used as the key for CompositeComponentBeanInfo instances.

If the UnmappedResourceHandler isn't used, the key contains ResourceImpl. The difference is that UnmappedResource does not implement equals() as ResourceImpl does:

@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }
    if (o == null || getClass() != o.getClass()) {
        return false;
    }

    ResourceImpl resource = (ResourceImpl) o;
    return resourceInfo.equals(resource.resourceInfo);
}

So problem seems that in the first case CompositeComponentBeanInfo is added again and again to the metadataCache. In the second everything works as expected.

Anyone else can confirm this issue?


Solution

  • UnmappedResourceHandler memory leak on composite components is confirmed and has been solved by this commit for 2.1, this commit for 1.11 and this commit for 1.8.3.

    All versions are as of today available in Maven.