cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r666706 - in /cxf/branches/2.0.x-fixes: ./ rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java
Date Wed, 11 Jun 2008 15:32:27 GMT
Author: dkulp
Date: Wed Jun 11 08:32:27 2008
New Revision: 666706

URL: http://svn.apache.org/viewvc?rev=666706&view=rev
Log:
Merged revisions 666084 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r666084 | bharath | 2008-06-10 08:18:56 -0400 (Tue, 10 Jun 2008) | 2 lines
  
  [CXF-1621] Fix for several memory leak issues. 
  http://www.nabble.com/Memory-Leak-at-WSDLManagerImpl-td17579537.html
........

Modified:
    cxf/branches/2.0.x-fixes/   (props changed)
    cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java

Propchange: cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java?rev=666706&r1=666705&r2=666706&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java
Wed Jun 11 08:32:27 2008
@@ -20,6 +20,7 @@
 package org.apache.cxf.wsdl11;
 
 import java.io.IOException;
+import java.lang.ref.WeakReference;
 import java.net.URL;
 import java.util.Collections;
 import java.util.Iterator;
@@ -72,7 +73,17 @@
     final ExtensionRegistry registry;
     final WSDLFactory factory;
     final Map<Object, Definition> definitionsMap;
-    final Map<Definition, ServiceSchemaInfo> schemaCacheMap; 
+    
+    /**
+     * The schemaCacheMap is used as a cache of SchemaInfo against the WSDLDefinitions.
+     * Note that the value is a WeakReference of ServiceSchemaInfo - Here the ServiceSchemaInfo
in turn holds
+     * the key WSDL Definition. Since the value always strongly refers to the key, we make
the value also
+     * weak - so that whenever their is no external strong reference to the key, the entry
will qualify for
+     * removal from the map.
+     * https://issues.apache.org/jira/browse/CXF-1621
+     *
+     */
+    final Map<Definition, WeakReference<ServiceSchemaInfo>> schemaCacheMap;
     private boolean disableSchemaCache;
     
     private Bus bus;
@@ -97,7 +108,7 @@
             throw new BusException(e);
         }
         definitionsMap = new CacheMap<Object, Definition>();
-        schemaCacheMap = new CacheMap<Definition, ServiceSchemaInfo>();
+        schemaCacheMap = new CacheMap<Definition, WeakReference<ServiceSchemaInfo>>();
 
         registerInitialExtensions();
     }
@@ -200,7 +211,7 @@
         ResourceManagerWSDLLocator wsdlLocator = new ResourceManagerWSDLLocator(url,
                                                                                 catLocator,
                                                                                 bus);
-        
+    
         Definition def = reader.readWSDL(wsdlLocator);
         synchronized (definitionsMap) {
             definitionsMap.put(url, def);
@@ -242,15 +253,18 @@
             return null;
         }
         synchronized (schemaCacheMap) {
-            return schemaCacheMap.get(wsdl);
+            WeakReference<ServiceSchemaInfo> weakReference = schemaCacheMap.get(wsdl);
+            if (weakReference != null) {
+                return weakReference.get();
+            }
         }
-        
+        return null;
     }
 
     public void putSchemasForDefinition(Definition wsdl, ServiceSchemaInfo schemas) {
         if (!disableSchemaCache) {
             synchronized (schemaCacheMap) {
-                schemaCacheMap.put(wsdl, schemas);
+                schemaCacheMap.put(wsdl, new WeakReference<ServiceSchemaInfo>(schemas));
             }
         }
         



Mime
View raw message