Author: markt
Date: Thu Nov 23 18:36:35 2017
New Revision: 1816181

URL: http://svn.apache.org/viewvc?rev=1816181&view=rev
Log:
Reduce instances of logging, rethrowing and logging again when an exception 
occurs for a connector. One log message is sufficient.

Modified:
    tomcat/tc8.5.x/trunk/java/org/apache/coyote/AbstractProtocol.java

Modified: tomcat/tc8.5.x/trunk/java/org/apache/coyote/AbstractProtocol.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/coyote/AbstractProtocol.java?rev=1816181&r1=1816180&r2=1816181&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/java/org/apache/coyote/AbstractProtocol.java (original)
+++ tomcat/tc8.5.x/trunk/java/org/apache/coyote/AbstractProtocol.java Thu Nov 
23 18:36:35 2017
@@ -616,13 +616,7 @@ public abstract class AbstractProtocol<S
         String endpointName = getName();
         endpoint.setName(endpointName.substring(1, endpointName.length()-1));
 
-        try {
-            endpoint.init();
-        } catch (Exception ex) {
-            getLog().error(sm.getString("abstractProtocolHandler.initError",
-                    getName()), ex);
-            throw ex;
-        }
+        endpoint.init();
     }
 
 
@@ -631,13 +625,8 @@ public abstract class AbstractProtocol<S
         if (getLog().isInfoEnabled())
             getLog().info(sm.getString("abstractProtocolHandler.start",
                     getName()));
-        try {
-            endpoint.start();
-        } catch (Exception ex) {
-            getLog().error(sm.getString("abstractProtocolHandler.startError",
-                    getName()), ex);
-            throw ex;
-        }
+
+        endpoint.start();
 
         // Start async timeout thread
         asyncTimeout = new AsyncTimeout();
@@ -657,13 +646,8 @@ public abstract class AbstractProtocol<S
         if(getLog().isInfoEnabled())
             getLog().info(sm.getString("abstractProtocolHandler.pause",
                     getName()));
-        try {
-            endpoint.pause();
-        } catch (Exception ex) {
-            getLog().error(sm.getString("abstractProtocolHandler.pauseError",
-                    getName()), ex);
-            throw ex;
-        }
+
+        endpoint.pause();
     }
 
     @Override
@@ -671,13 +655,8 @@ public abstract class AbstractProtocol<S
         if(getLog().isInfoEnabled())
             getLog().info(sm.getString("abstractProtocolHandler.resume",
                     getName()));
-        try {
-            endpoint.resume();
-        } catch (Exception ex) {
-            getLog().error(sm.getString("abstractProtocolHandler.resumeError",
-                    getName()), ex);
-            throw ex;
-        }
+
+        endpoint.resume();
     }
 
 
@@ -691,56 +670,47 @@ public abstract class AbstractProtocol<S
             asyncTimeout.stop();
         }
 
-        try {
-            endpoint.stop();
-        } catch (Exception ex) {
-            getLog().error(sm.getString("abstractProtocolHandler.stopError",
-                    getName()), ex);
-            throw ex;
-        }
+        endpoint.stop();
     }
 
 
     @Override
-    public void destroy() {
+    public void destroy() throws Exception {
         if(getLog().isInfoEnabled()) {
             getLog().info(sm.getString("abstractProtocolHandler.destroy",
                     getName()));
         }
         try {
             endpoint.destroy();
-        } catch (Exception e) {
-            getLog().error(sm.getString("abstractProtocolHandler.destroyError",
-                    getName()), e);
-        }
-
-        if (oname != null) {
-            if (mserver == null) {
-                Registry.getRegistry(null, null).unregisterComponent(oname);
-            } else {
-                // Possibly registered with a different MBeanServer
-                try {
-                    mserver.unregisterMBean(oname);
-                } catch (MBeanRegistrationException |
-                        InstanceNotFoundException e) {
-                    getLog().info(sm.getString(
-                            "abstractProtocol.mbeanDeregistrationFailed",
-                            oname, mserver));
+        } finally {
+            if (oname != null) {
+                if (mserver == null) {
+                    Registry.getRegistry(null, 
null).unregisterComponent(oname);
+                } else {
+                    // Possibly registered with a different MBeanServer
+                    try {
+                        mserver.unregisterMBean(oname);
+                    } catch (MBeanRegistrationException |
+                            InstanceNotFoundException e) {
+                        getLog().info(sm.getString(
+                                "abstractProtocol.mbeanDeregistrationFailed",
+                                oname, mserver));
+                    }
                 }
             }
-        }
 
-        if (tpOname != null) {
-            Registry.getRegistry(null, null).unregisterComponent(tpOname);
-        }
-        if (rgOname != null) {
-            Registry.getRegistry(null, null).unregisterComponent(rgOname);
-        }
-        for (ObjectName sslOname : sslOnames) {
-            Registry.getRegistry(null, null).unregisterComponent(sslOname);
-        }
-        for (ObjectName sslCertOname : sslCertOnames) {
-            Registry.getRegistry(null, null).unregisterComponent(sslCertOname);
+            if (tpOname != null) {
+                Registry.getRegistry(null, null).unregisterComponent(tpOname);
+            }
+            if (rgOname != null) {
+                Registry.getRegistry(null, null).unregisterComponent(rgOname);
+            }
+            for (ObjectName sslOname : sslOnames) {
+                Registry.getRegistry(null, null).unregisterComponent(sslOname);
+            }
+            for (ObjectName sslCertOname : sslCertOnames) {
+                Registry.getRegistry(null, 
null).unregisterComponent(sslCertOname);
+            }
         }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to