More unit test fixes - better handling when APR/native connector is not started
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 27 Jul 2010 22:36:06 +0000 (22:36 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 27 Jul 2010 22:36:06 +0000 (22:36 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@979896 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/tomcat/util/net/AprEndpoint.java

index e6a3a33..bf60c98 100644 (file)
@@ -702,27 +702,27 @@ public class AprEndpoint extends AbstractEndpoint {
         if (running) {
             stop();
         }
-        try {
+        
+        // Destroy pool if it was initialised
+        if (serverSockPool != 0) {
             Pool.destroy(serverSockPool);
-        } catch (UnsatisfiedLinkError e) {
-            // Ignore - APR was not initialised
+            serverSockPool = 0;
         }
-        serverSockPool = 0;
-        // Close server socket
-        try {
+        
+        // Close server socket if it was initialised
+        if (serverSock != 0) {
             Socket.close(serverSock);
-        } catch (UnsatisfiedLinkError e) {
-            // Ignore - APR was not initialised
+            serverSock = 0;
         }
-        serverSock = 0;
+        
         sslContext = 0;
-        // Close all APR memory pools and resources
-        try {
+        
+        // Close all APR memory pools and resources if initialised
+        if (rootPool != 0) {
             Pool.destroy(rootPool);
-        } catch (UnsatisfiedLinkError e) {
-            // Ignore - APR was not initialised
+            rootPool = 0;
         }
-        rootPool = 0;
+        
         initialized = false;
     }