cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r518544 - in /incubator/cxf/trunk/rt: ./ core/src/main/java/org/apache/cxf/endpoint/ core/src/test/java/org/apache/cxf/endpoint/ frontend/jaxws/src/main/java/org/apache/cxf/jaxws/
Date Thu, 15 Mar 2007 09:31:53 GMT
Author: ningjiang
Date: Thu Mar 15 02:31:52 2007
New Revision: 518544

URL: http://svn.apache.org/viewvc?view=rev&rev=518544
Log:
[CXF-457, CXF-458] Fixed the memory leak of ServerRegistry and ThreadLocal

Modified:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerRegistryImpl.java
    incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/endpoint/ServerRegistryImpTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java
    incubator/cxf/trunk/rt/pom.xml

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java?view=diff&rev=518544&r1=518543&r2=518544
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java Thu
Mar 15 02:31:52 2007
@@ -87,9 +87,13 @@
 
     public void stop() {
         LOG.fine("Server is stopping.");
-        getDestination().setMessageObserver(null);  
         if (mgr != null) {
             mgr.stopServer(this);
+        }
+        getDestination().setMessageObserver(null);
+        if (null != serverRegistry) {
+            LOG.fine("unregister the server to serverRegistry ");
+            serverRegistry.unregister(this);
         }
     }
 

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerRegistryImpl.java?view=diff&rev=518544&r1=518543&r2=518544
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerRegistryImpl.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerRegistryImpl.java
Thu Mar 15 02:31:52 2007
@@ -79,15 +79,18 @@
 
     @PreDestroy
     public void preShutdown() {
-        // Shutdown the service       
-        for (Server server : serversList) {            
+        // Shutdown the service.
+        // To avoid the CurrentModificationException, do not use serversList directly 
+        Object[] servers = serversList.toArray();
+        for (int i = 0; i < servers.length; i++) {
+            Server server = (Server) servers[i];
             server.stop();
-        }
+        }        
     }
 
     public void postShutdown() {
-        // TODO Auto-generated method stub
-        
+        // Clean the serversList
+        serversList.clear();
     }
 
 }

Modified: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/endpoint/ServerRegistryImpTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/endpoint/ServerRegistryImpTest.java?view=diff&rev=518544&r1=518543&r2=518544
==============================================================================
--- incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/endpoint/ServerRegistryImpTest.java
(original)
+++ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/endpoint/ServerRegistryImpTest.java
Thu Mar 15 02:31:52 2007
@@ -19,22 +19,23 @@
 
 package org.apache.cxf.endpoint;
 
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
 
-import org.easymock.classextension.EasyMock;
-
-public class ServerRegistryImpTest extends TestCase {
+public class ServerRegistryImpTest extends Assert {
     
+    @Test
     public void testServerRegistryPreShutdown() {
         ServerRegistryImpl serverRegistryImpl = new ServerRegistryImpl();        
-        Server server = EasyMock.createMock(Server.class);
-        EasyMock.reset(server);
-        server.stop();
-        EasyMock.expectLastCall();
-        EasyMock.replay(server);
-        serverRegistryImpl.register(server);
+        Server server = new DummyServer(serverRegistryImpl);
+        server.start();
+        assertEquals("The serverList should have one service", serverRegistryImpl.serversList.size(),
1);
         serverRegistryImpl.preShutdown();
-        EasyMock.verify(server);
-    }
+        assertEquals("The serverList should be clear ", serverRegistryImpl.serversList.size(),
0);
+        serverRegistryImpl.postShutdown();
+        assertEquals("The serverList should be clear ", serverRegistryImpl.serversList.size(),
0);
+    }    
+    
+    
 
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java?view=diff&rev=518544&r1=518543&r2=518544
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java
Thu Mar 15 02:31:52 2007
@@ -64,6 +64,8 @@
         
         //update the webservice response context
         ContextPropertiesMapping.updateWebServiceContext(exchange, ctx);
+        //clear the WebServiceContextImpl's ThreadLocal variable
+        WebServiceContextImpl.clear();
         return res;
     }
 }

Modified: incubator/cxf/trunk/rt/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/pom.xml?view=diff&rev=518544&r1=518543&r2=518544
==============================================================================
--- incubator/cxf/trunk/rt/pom.xml (original)
+++ incubator/cxf/trunk/rt/pom.xml Thu Mar 15 02:31:52 2007
@@ -40,7 +40,6 @@
         <module>frontend/simple</module>
         <module>frontend/jaxws</module>
         <module>frontend/js</module>
-        <module>transports/http</module>
         <module>transports/http2</module>
         <module>transports/jms</module>
         <module>ws/policy</module>



Mime
View raw message