Skip to content

Commit

Permalink
LPS-25946 Instanceable portlet on removal from page does not clear up…
Browse files Browse the repository at this point in the history
… InvokerPortlet cache causing memory leak
  • Loading branch information
shuyangzhou authored and brianchandotcom committed Mar 7, 2012
1 parent 8f070b5 commit 4500c48
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
Expand Up @@ -59,6 +59,7 @@
import com.liferay.portal.util.PropsUtil;
import com.liferay.portal.util.PropsValues;
import com.liferay.portlet.PortalPreferences;
import com.liferay.portlet.PortletInstanceFactoryUtil;
import com.liferay.portlet.PortletPreferencesFactoryUtil;
import com.liferay.portlet.sites.util.SitesUtil;
import com.liferay.util.JS;
Expand Down Expand Up @@ -941,6 +942,8 @@ public void removePortletId(
return;
}

PortletInstanceFactoryUtil.delete(portlet);

PermissionChecker permissionChecker =
PermissionThreadLocal.getPermissionChecker();

Expand Down
Expand Up @@ -182,6 +182,17 @@ public InvokerPortlet create(Portlet portlet, ServletContext servletContext)
return instanceInvokerPortletInstance;
}

public void delete(Portlet portlet) {
if (PortletConstants.getInstanceId(portlet.getPortletId()) != null) {
Map<String, InvokerPortlet> portletInstances = _pool.get(
portlet.getRootPortletId());

if (portletInstances != null) {
portletInstances.remove(portlet.getPortletId());
}
}
}

public void destroy() {

// LPS-10473
Expand Down
Expand Up @@ -32,6 +32,8 @@ public interface PortletInstanceFactory {
public InvokerPortlet create(Portlet portlet, ServletContext servletContext)
throws PortletException;

public void delete(Portlet portlet);

public void destroy(Portlet portlet);

}
Expand Up @@ -40,6 +40,10 @@ public static InvokerPortlet create(
return getPortletInstanceFactory().create(portlet, servletContext);
}

public static void delete(Portlet portlet) {
getPortletInstanceFactory().delete(portlet);
}

public static void destroy(Portlet portlet) {
getPortletInstanceFactory().destroy(portlet);
}
Expand Down

0 comments on commit 4500c48

Please sign in to comment.