myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1623879 - /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeBeanHolder.java
Date Tue, 09 Sep 2014 20:29:08 GMT
Author: lu4242
Date: Tue Sep  9 20:29:07 2014
New Revision: 1623879

URL: http://svn.apache.org/r1623879
Log:
MYFACES-3924 Memory leak in ViewScopeBeanHolder

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeBeanHolder.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeBeanHolder.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeBeanHolder.java?rev=1623879&r1=1623878&r2=1623879&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeBeanHolder.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeBeanHolder.java
Tue Sep  9 20:29:07 2014
@@ -145,27 +145,35 @@ public class ViewScopeBeanHolder impleme
         ViewScopeContextualStorage contextualStorage = storageMap.get(viewScopeId);
         if (contextualStorage != null)
         {
-            FacesContext facesContext = FacesContext.getCurrentInstance();
-            if (facesContext == null &&
-                applicationContextBean.getServletContext() != null)
+            try
             {
-                try
+                FacesContext facesContext = FacesContext.getCurrentInstance();
+                if (facesContext == null &&
+                    applicationContextBean.getServletContext() != null)
                 {
-                    ServletContext servletContext = applicationContextBean.getServletContext();
-                    ExternalContext externalContext = new StartupServletExternalContextImpl(servletContext,
false);
-                    ExceptionHandler exceptionHandler = new ExceptionHandlerImpl();
-                    facesContext = new StartupFacesContextImpl(externalContext, 
-                            (ReleaseableExternalContext) externalContext, exceptionHandler,
false);
-                    ViewScopeContextImpl.destroyAllActive(contextualStorage);
+                    try
+                    {
+                        ServletContext servletContext = applicationContextBean.getServletContext();
+                        ExternalContext externalContext = new StartupServletExternalContextImpl(servletContext,
false);
+                        ExceptionHandler exceptionHandler = new ExceptionHandlerImpl();
+                        facesContext = new StartupFacesContextImpl(externalContext, 
+                                (ReleaseableExternalContext) externalContext, exceptionHandler,
false);
+                        ViewScopeContextImpl.destroyAllActive(contextualStorage);
+                    }
+                    finally
+                    {
+                        facesContext.release();
+                    }
                 }
-                finally
+                else
                 {
-                    facesContext.release();
+                    ViewScopeContextImpl.destroyAllActive(contextualStorage);
                 }
             }
-            else
+            finally
             {
-                ViewScopeContextImpl.destroyAllActive(contextualStorage);
+                //remove the viewScopeId to prevent memory leak
+                storageMap.remove(viewScopeId);
             }
         }
     }



Mime
View raw message