Author: kkolinko
Date: Thu Jan 7 06:12:35 2016
New Revision: 1723466
URL: http://svn.apache.org/viewvc?rev=1723466&view=rev
Log:
Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=51503
Add additional validation that prevents a connector from starting if it does
not have a valid port number.
A backport of r1147949.
Implementation notes:
1. Port number default was changed to -1, as somebody may actually use the
value of 0, and in view of future implementation of BZ 52028
2. The check in start() method is located after registration of a JMX bean.
The reason is that somebody may use JMX to reconfigure a connector.
In Tomcat 7 the JMX registration is performed at init time (in
LifecycleMBeanBase.initInternal())
Modified:
tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Connector.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/LocalStrings.properties
tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Connector.java
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Connector.java?rev=1723466&r1=1723465&r2=1723466&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Connector.java
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Connector.java Thu
Jan 7 06:12:35 2016
@@ -146,7 +146,7 @@ public class Connector
/**
* The port number on which we listen for requests.
*/
- protected int port = 0;
+ protected int port = -1;
/**
@@ -1192,6 +1192,12 @@ public class Connector
("coyoteConnector.cannotRegisterProtocol"));
}
+ // Validate settings before starting
+ if (getPort() < 0) {
+ throw new LifecycleException(sm.getString(
+ "coyoteConnector.invalidPort", String.valueOf(getPort())));
+ }
+
try {
protocolHandler.start();
} catch (Exception e) {
Modified:
tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/LocalStrings.properties
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/LocalStrings.properties?rev=1723466&r1=1723465&r2=1723466&view=diff
==============================================================================
---
tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/LocalStrings.properties
(original)
+++
tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/LocalStrings.properties
Thu Jan 7 06:12:35 2016
@@ -20,6 +20,7 @@
coyoteConnector.alreadyInitialized=The connector has already been initialized
coyoteConnector.alreadyStarted=The connector has already been started
coyoteConnector.cannotRegisterProtocol=Cannot register MBean for the Protocol
+coyoteConnector.invalidPort=The connector cannot start since the specified
port value of [{0}] is invalid
coyoteConnector.notStarted=Coyote connector has not been started
coyoteConnector.protocolHandlerDestroyFailed=Protocol handler destroy failed:
{0}
coyoteConnector.protocolHandlerInitializationFailed=Protocol handler
initialization failed: {0}
Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=1723466&r1=1723465&r2=1723466&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Thu Jan 7 06:12:35 2016
@@ -112,6 +112,10 @@
implementation to ease future maintenance. (markt)
</add>
<fix>
+ <bug>51503</bug>: Add additional validation that prevents a connector
+ from starting if it does not have a valid port number. (kkolinko)
+ </fix>
+ <fix>
<bug>52926</bug>: Avoid NPE when an NIO Comet connection times out on
one thread at the same time as it is closed on another thread.
(markt/kkolinko)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]