cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1440697 - /cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
Date Wed, 30 Jan 2013 22:02:34 GMT
Author: dkulp
Date: Wed Jan 30 22:02:34 2013
New Revision: 1440697

URL: http://svn.apache.org/viewvc?rev=1440697&view=rev
Log:
Merged revisions 1440148 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1440148 | dkulp | 2013-01-29 16:28:34 -0500 (Tue, 29 Jan 2013) | 2 lines

  [CXF-4795] Prevent a potential memory leak where the spring bean factory will hold onto
string reps of every URL ever used.

........

Modified:
    cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java

Modified: cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java?rev=1440697&r1=1440696&r2=1440697&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
(original)
+++ cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
Wed Jan 30 22:02:34 2013
@@ -38,9 +38,11 @@ import org.apache.cxf.common.logging.Log
 import org.apache.cxf.configuration.Configurable;
 import org.apache.cxf.configuration.Configurer;
 import org.apache.cxf.extension.BusExtension;
+import org.springframework.beans.factory.BeanFactory;
 import org.springframework.beans.factory.NoSuchBeanDefinitionException;
 import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
 import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.AbstractBeanFactory;
 import org.springframework.beans.factory.support.BeanDefinitionRegistry;
 import org.springframework.beans.factory.wiring.BeanConfigurerSupport;
 import org.springframework.beans.factory.wiring.BeanWiringInfo;
@@ -58,6 +60,7 @@ public class ConfigurerImpl extends Bean
     private Set<ApplicationContext> appContexts;
     private final Map<String, List<MatcherHolder>> wildCardBeanDefinitions
         = new HashMap<String, List<MatcherHolder>>();
+    private BeanFactory beanFactory;
     
     static class MatcherHolder {
         Matcher matcher;
@@ -76,6 +79,11 @@ public class ConfigurerImpl extends Bean
         setApplicationContext(ac);
     }
         
+    public void setBeanFactory(BeanFactory beanFactory) {
+        this.beanFactory = beanFactory;
+        super.setBeanFactory(beanFactory);
+    }
+    
     private void initWildcardDefinitionMap() {
         if (null != appContexts) {
             for (ApplicationContext appContext : appContexts) {
@@ -153,6 +161,12 @@ public class ConfigurerImpl extends Bean
         }
         
         try {
+            //this will prevent a call into the AbstractBeanFactory.markBeanAsCreated(...)
+            //which saves ALL the names into a HashSet.  For URL based configuration,
+            //this can leak memory
+            if (beanFactory instanceof AbstractBeanFactory) {
+                ((AbstractBeanFactory)beanFactory).getMergedBeanDefinition(bn);
+            }
             super.configureBean(beanInstance);
             if (LOG.isLoggable(Level.FINE)) {
                 LOG.fine("Successfully performed injection.");
@@ -228,7 +242,8 @@ public class ConfigurerImpl extends Bean
     public final void setApplicationContext(ApplicationContext ac) {
         appContexts = new CopyOnWriteArraySet<ApplicationContext>();
         addApplicationContext(ac);
-        setBeanFactory(ac.getAutowireCapableBeanFactory());
+        this.beanFactory = ac.getAutowireCapableBeanFactory();
+        super.setBeanFactory(this.beanFactory);
     }
     
     public final void addApplicationContext(ApplicationContext ac) {



Mime
View raw message