tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r1766514 - in /tomcat/trunk: java/org/apache/catalina/startup/Tomcat.java webapps/docs/changelog.xml
Date Tue, 25 Oct 2016 11:34:16 GMT
Author: remm
Date: Tue Oct 25 11:34:16 2016
New Revision: 1766514

URL: http://svn.apache.org/viewvc?rev=1766514&view=rev
Log:
60297: Improve connector handling in embedded mode.

Modified:
    tomcat/trunk/java/org/apache/catalina/startup/Tomcat.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/catalina/startup/Tomcat.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/Tomcat.java?rev=1766514&r1=1766513&r2=1766514&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/Tomcat.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/Tomcat.java Tue Oct 25 11:34:16 2016
@@ -138,7 +138,6 @@ public class Tomcat {
     protected Server server;
     protected Service service;
     protected Engine engine;
-    protected Connector connector; // for more - customize the classes
 
     // To make it a bit easier to config for the common case
     // ( one host, one context ).
@@ -417,23 +416,32 @@ public class Tomcat {
      * @return A connector object that can be customized
      */
     public Connector getConnector() {
-        getServer();
-        if (connector != null) {
-            return connector;
+        Service service = getService();
+        if (service.findConnectors().length > 0) {
+            return service.findConnectors()[0];
         }
 
         // The same as in standard Tomcat configuration.
         // This creates an APR HTTP connector if AprLifecycleListener has been
         // configured (created) and Tomcat Native library is available.
         // Otherwise it creates a NIO HTTP connector.
-        connector = new Connector("HTTP/1.1");
+        Connector connector = new Connector("HTTP/1.1");
         connector.setPort(port);
-        service.addConnector( connector );
+        service.addConnector(connector);
         return connector;
     }
 
     public void setConnector(Connector connector) {
-        this.connector = connector;
+        Service service = getService();
+        boolean found = false;
+        for (Connector serviceConnector : service.findConnectors()) {
+            if (connector == serviceConnector) {
+                found = true;
+            }
+        }
+        if (!found) {
+            service.addConnector(connector);
+        }
     }
 
     /**

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1766514&r1=1766513&r2=1766514&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Tue Oct 25 11:34:16 2016
@@ -80,6 +80,9 @@
         Correctly test for control characters when reading the provided shutdown
         password. (markt)
       </fix>
+      <fix>
+        <bug>60297</bug>: Simplify connector creation in embedded mode. (remm)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">



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


Mime
View raw message