Author: markt
Date: Wed Jun  6 12:44:29 2018
New Revision: 1833016

URL: http://svn.apache.org/viewvc?rev=1833016&view=rev
Log:
Correct the logic in MBeanFactory.removeConnector() to ensure that the correct 
Connector is removed when there are multiple Connectors using different 
addresses but the same port.

Modified:
    tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java?rev=1833016&r1=1833015&r2=1833016&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java (original)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java Wed Jun  6 
12:44:29 2018
@@ -18,6 +18,7 @@
 package org.apache.catalina.mbeans;
 
 import java.io.File;
+import java.net.InetAddress;
 
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
@@ -685,29 +686,32 @@ public class MBeanFactory {
         ObjectName oname = new ObjectName(name);
         Service service = getService(oname);
         String port = oname.getKeyProperty("port");
-        //String address = oname.getKeyProperty("address");
+        String address = ObjectName.unquote(oname.getKeyProperty("address"));
 
         Connector conns[] = service.findConnectors();
 
         for (int i = 0; i < conns.length; i++) {
-            String connAddress = 
String.valueOf(conns[i].getProperty("address"));
+            String connAddress = null;
+            Object objConnAddress = conns[i].getProperty("address");
+            if (objConnAddress != null) {
+                connAddress = ((InetAddress) objConnAddress).getHostAddress();
+            }
             String connPort = ""+conns[i].getPort();
 
-            // if (((address.equals("null")) &&
-            if ((connAddress==null) && port.equals(connPort)) {
-                service.removeConnector(conns[i]);
-                conns[i].destroy();
-                break;
-            }
-            // } else if (address.equals(connAddress))
-            if (port.equals(connPort)) {
-                // Remove this component from its parent component
+            if (address == null) {
+                // Don't combine this with outer if or we could get an NPE in
+                // 'else if' below
+                if (connAddress == null && port.equals(connPort)) {
+                    service.removeConnector(conns[i]);
+                    conns[i].destroy();
+                    break;
+                }
+            } else if (address.equals(connAddress) && port.equals(connPort)) {
                 service.removeConnector(conns[i]);
                 conns[i].destroy();
                 break;
             }
         }
-
     }
 
 

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1833016&r1=1833015&r2=1833016&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Wed Jun  6 12:44:29 2018
@@ -143,6 +143,11 @@
         <code>trustedProxies</code> but no <code>internalProxies</code>. Based
         on a patch by zhanhb. (markt)
       </fix>
+      <fix>
+        Correct the logic in <code>MBeanFactory.removeConnector()</code> to
+        ensure that the correct Connector is removed when there are multiple
+        Connectors using different addresses but the same port. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">



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

Reply via email to