You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Konstantin Triger (JIRA)" <de...@myfaces.apache.org> on 2008/01/02 17:05:34 UTC

[jira] Created: (MYFACES-1796) FactoryFinder.releaseFactories() does not release application class loader. (PATCH available).

FactoryFinder.releaseFactories() does not release application class loader. (PATCH available).
----------------------------------------------------------------------------------------------

                 Key: MYFACES-1796
                 URL: https://issues.apache.org/jira/browse/MYFACES-1796
             Project: MyFaces Core
          Issue Type: Bug
          Components: JSR-127
    Affects Versions:  1.2.0, 1.1.5
            Reporter: Konstantin Triger


FactoryFinder._registeredFactoryNames holds the Web application class loader as a key and thus prevents its collection when the application is undeployed.

The following patch fixes the issue (made in 1.1.5 branch):

Index: FactoryFinder.java
===================================================================
--- FactoryFinder.java  (revision 608034)
+++ FactoryFinder.java  (working copy)
@@ -40,7 +40,7 @@
     public static final String LIFECYCLE_FACTORY = "javax.faces.lifecycle.LifecycleFactory";
     public static final String RENDER_KIT_FACTORY = "javax.faces.render.RenderKitFactory";

-    private static Map _registeredFactoryNames = new HashMap();
+    private static Map _registeredFactoryNames = Collections.synchronizedMap(new HashMap());
     /**
      * Maps from classLoader to another map, the container (i.e. Tomcat) will create a class loader for
      * each web app that it controls (typically anyway) and that class loader is used as the key.
@@ -49,7 +49,7 @@
      * that are created via getFactory. The instances will be of the class specified in the setFactory method
      * for the factory name, i.e. FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, MyFactory.class).
      */
-    private static Map _factories = new HashMap();
+    private static Map _factories = Collections.synchronizedMap(new HashMap());

     private static final Set VALID_FACTORY_NAMES = new HashSet();
     private static final Map ABSTRACT_FACTORY_CLASSES = new HashMap();
@@ -222,6 +222,7 @@
     {
         ClassLoader classLoader = getClassLoader();
         _factories.remove(classLoader);
+        _registeredFactoryNames.remove(classLoader);
     }

     private static void checkFactoryName(String factoryName)


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MYFACES-1796) FactoryFinder.releaseFactories() does not release application class loader. (PATCH available).

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-1796?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12585268#action_12585268 ] 

Leonardo Uribe commented on MYFACES-1796:
-----------------------------------------

Yes, the problem presented is clear. But I think that it is better to synchronize some parts of the code instead use synchronized HashMaps. The access to  _registeredFactoryNames on getFactory must be synchronized to avoid effects. And the value retrieved through classLoader (a Map) must be cleaned for allow gc recolect memory.

I will do more tests about this and commit a modifications of the proposal

> FactoryFinder.releaseFactories() does not release application class loader. (PATCH available).
> ----------------------------------------------------------------------------------------------
>
>                 Key: MYFACES-1796
>                 URL: https://issues.apache.org/jira/browse/MYFACES-1796
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-127
>    Affects Versions: 1.1.5,  1.2.0
>            Reporter: Konstantin Triger
>            Assignee: Leonardo Uribe
>
> FactoryFinder._registeredFactoryNames holds the Web application class loader as a key and thus prevents its collection when the application is undeployed.
> The following patch fixes the issue (made in 1.1.5 branch):
> Index: FactoryFinder.java
> ===================================================================
> --- FactoryFinder.java  (revision 608034)
> +++ FactoryFinder.java  (working copy)
> @@ -40,7 +40,7 @@
>      public static final String LIFECYCLE_FACTORY = "javax.faces.lifecycle.LifecycleFactory";
>      public static final String RENDER_KIT_FACTORY = "javax.faces.render.RenderKitFactory";
> -    private static Map _registeredFactoryNames = new HashMap();
> +    private static Map _registeredFactoryNames = Collections.synchronizedMap(new HashMap());
>      /**
>       * Maps from classLoader to another map, the container (i.e. Tomcat) will create a class loader for
>       * each web app that it controls (typically anyway) and that class loader is used as the key.
> @@ -49,7 +49,7 @@
>       * that are created via getFactory. The instances will be of the class specified in the setFactory method
>       * for the factory name, i.e. FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, MyFactory.class).
>       */
> -    private static Map _factories = new HashMap();
> +    private static Map _factories = Collections.synchronizedMap(new HashMap());
>      private static final Set VALID_FACTORY_NAMES = new HashSet();
>      private static final Map ABSTRACT_FACTORY_CLASSES = new HashMap();
> @@ -222,6 +222,7 @@
>      {
>          ClassLoader classLoader = getClassLoader();
>          _factories.remove(classLoader);
> +        _registeredFactoryNames.remove(classLoader);
>      }
>      private static void checkFactoryName(String factoryName)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.