[exo-jcr-commits] exo-jcr SVN: r5551 - in kernel/branches/2.2.x: exo.kernel.container/src/test/java/org/exoplatform/container and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Feb 1 07:19:30 EST 2012


Author: trang_vu
Date: 2012-02-01 07:19:28 -0500 (Wed, 01 Feb 2012)
New Revision: 5551

Added:
   kernel/branches/2.2.x/patch/2.2.12-GA/KER-181/readme.txt
Modified:
   kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Configuration.java
   kernel/branches/2.2.x/exo.kernel.container/src/test/java/org/exoplatform/container/TestPortalContainer.java
Log:
KER-181: PortalContainer.getConfigurationXML() returns duplicated configuration

Fix description
    * The method PortalContainer.getConfigurationXML() requires to merge the configuration of the RootContainer with the configuration of the Portal container to get the effiency. This merge is allowed by cloning the configuration of the RootContainer and adding the configuration of the portal container. The problem here was the fact that the object was badly cloned which had for consequence to grow up at each method call.
    * Fixed by rewriting clone() method.


Modified: kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Configuration.java
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Configuration.java	2012-02-01 10:41:22 UTC (rev 5550)
+++ kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Configuration.java	2012-02-01 12:19:28 UTC (rev 5551)
@@ -257,16 +257,8 @@
          }
          else if (result == null)
          {
-            try
-            {
-               // Initialize with the clone of the first non null configuration 
-               result = (Configuration)conf.clone();
-            }
-            catch (CloneNotSupportedException e)
-            {
-               log.warn("Could not clone the configuration", e);
-               break;
-            }
+            // Initialize with the clone of the first non null configuration 
+            result = (Configuration)conf.clone();
          }
          else
          {
@@ -276,8 +268,44 @@
       }
       return result;
    }
-
+   
    /**
+    * {@inheritDoc}
+    */
+   @SuppressWarnings("unchecked")
+   @Override
+   protected Object clone()
+   {
+      try
+      {
+         Configuration conf = (Configuration)super.clone();
+         conf.component_ = (Map<String, Component>)((HashMap<String, Component>)component_).clone();
+         conf.componentLifecyclePlugin_ =
+            (Map<String, ComponentLifecyclePlugin>)((HashMap<String, ComponentLifecyclePlugin>)componentLifecyclePlugin_)
+               .clone();
+         conf.containerLifecyclePlugin_ =
+            (Map<String, ContainerLifecyclePlugin>)((HashMap<String, ContainerLifecyclePlugin>)containerLifecyclePlugin_)
+               .clone();
+         conf.externalComponentPlugins_ =
+            (Map<String, ExternalComponentPlugins>)((HashMap<String, ExternalComponentPlugins>)externalComponentPlugins_)
+               .clone();
+         if (imports_ != null)
+         {
+            conf.imports_ = (ArrayList<String>)imports_.clone();
+         }
+         if (removeConfiguration_ != null)
+         {
+            conf.removeConfiguration_ = (ArrayList<String>)removeConfiguration_.clone();
+         }
+         return conf;
+      }
+      catch (CloneNotSupportedException e)
+      {
+         throw new AssertionError("Could not clone the configuration");
+      }
+   }
+   
+   /**
     * Dumps the configuration in XML format into the given {@link Writer}
     */
    public void toXML(Writer w)

Modified: kernel/branches/2.2.x/exo.kernel.container/src/test/java/org/exoplatform/container/TestPortalContainer.java
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/test/java/org/exoplatform/container/TestPortalContainer.java	2012-02-01 10:41:22 UTC (rev 5550)
+++ kernel/branches/2.2.x/exo.kernel.container/src/test/java/org/exoplatform/container/TestPortalContainer.java	2012-02-01 12:19:28 UTC (rev 5551)
@@ -161,6 +161,36 @@
       assertNull(PortalContainer.getCurrentSetting("boolean"));     
    }
    
+   public void testGetConfigurationXML()
+   {
+      URL rootURL = getClass().getResource("test-exo-container.xml");
+      URL portalURL = getClass().getResource("/conf/test-configuration.xml");
+      assertNotNull(rootURL);
+      assertNotNull(portalURL);
+      //
+      new ContainerBuilder().withRoot(rootURL).withPortal(portalURL).build();
+      
+      String configXML = RootContainer.getInstance().getConfigurationXML();
+      assertNotNull(configXML);
+      int size = configXML.length();
+      int hash = configXML.hashCode();
+      configXML = RootContainer.getInstance().getConfigurationXML();
+      assertNotNull(configXML);
+      assertTrue(size > 0);
+      assertEquals(size, configXML.length());
+      assertEquals(hash, configXML.hashCode());
+      
+      configXML = PortalContainer.getInstance().getConfigurationXML();
+      assertNotNull(configXML);
+      assertTrue(size > 0);
+      size = configXML.length();
+      hash = configXML.hashCode();
+      configXML = PortalContainer.getInstance().getConfigurationXML();
+      assertNotNull(configXML);
+      assertEquals(size, configXML.length());
+      assertEquals(hash, configXML.hashCode());
+   }
+   
    public static class MyComponent
    {
       private final InitParams params;

Added: kernel/branches/2.2.x/patch/2.2.12-GA/KER-181/readme.txt
===================================================================
--- kernel/branches/2.2.x/patch/2.2.12-GA/KER-181/readme.txt	                        (rev 0)
+++ kernel/branches/2.2.x/patch/2.2.12-GA/KER-181/readme.txt	2012-02-01 12:19:28 UTC (rev 5551)
@@ -0,0 +1,71 @@
+Summary
+
+    * Status: PortalContainer.getConfigurationXML() returns duplicated configuration
+    * CCP Issue: N/A Product Jira Issue: KER-181.
+    * Complexity: low
+
+The Proposal
+Problem description
+
+What is the problem to fix?
+
+    * The browser falls when getting configurationXML in services management. Getting configuration XML file from services management, pcontainer is exacting. When you are following steps to reproduce: in each loop it's slower and slower. In the end the browser fall - Unresponsive script (on windows). In linux it's just slow, but the browser doesn't fall.
+
+Fix description
+
+Problem analysis
+
+    * org.exoplatform.container.PortalContainer.getConfigurationXML() returns are duplicated each time it is called.
+
+How is the problem fixed?
+
+    * The method PortalContainer.getConfigurationXML() requires to merge the configuration of the RootContainer with the configuration of the Portal container to get the effiency. This merge is allowed by cloning the configuration of the RootContainer and adding the configuration of the portal container. The problem here was the fact that the object was badly cloned which had for consequence to grow up at each method call.
+    * Fixed by rewriting clone() method.
+
+Patch file: KER-181.patch
+
+Tests to perform
+
+Reproduction test
+* Access to the MBean related to your PortalContainer (using the jconsole for example) then call several times the method getConfigurationXML(). 
+** Before the patch application: the provided XML grows up.
+** After the patch, the provided XML should not grow up.
+
+Tests performed at DevLevel
+* testGetConfigurationXML()
+
+Tests performed at QA/Support Level
+*
+
+Documentation changes
+
+Documentation changes:
+* No
+
+Configuration changes
+
+Configuration changes:
+* No
+
+Will previous configuration continue to work?
+* Yes
+
+Risks and impacts
+
+Can this bug fix have any side effects on current client projects?
+
+    * Function or ClassName change: no
+
+Is there a performance risk/cost?
+* No
+
+Validation (PM/Support/QA)
+
+PM Comment
+* Patch validated.
+
+Support Comment
+*
+
+QA Feedbacks
+*



More information about the exo-jcr-commits mailing list