You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by lu...@apache.org on 2003/07/16 02:18:11 UTC
cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup Embedded.java
luehe 2003/07/15 17:18:11
Modified: catalina/src/share/org/apache/catalina/startup Embedded.java
Log:
- Added Embedded.createConnector() methods that take address of type
String (instead of java.net.InetAddress), since the InetAddress is
always converted to a string (and stored with the Connector's
properties) anyways
- Fixed problem that was caused by the fact that the InetAddress
passed to Embedded.createConnector() was converted to a string using
InetAddress.toString(), and added to the Connector's
properties. However, InetAddress.toString() returns a string of the
form "<hostname>/<literal_IP>".
Setting the address property on the underlying Http11Protocol would
always fail, because IntrospectionUtils.setProperty() would parse the
address string into an InetAddress like this:
InetAddress.getByName(value);
which throws a java.net.UnknownHostException (due to "value" being of
the form "<hostname>/<literal_IP>"). Unfortunately, the exception is
being swallowed.
The fix in Embedded.createConnector() checks of the address string
contains a '/', and only stores the IP part of the address with the
Connector's properties.
Revision Changes Path
1.8 +35 -10 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/Embedded.java
Index: Embedded.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/Embedded.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Embedded.java 29 May 2003 16:59:35 -0000 1.7
+++ Embedded.java 16 Jul 2003 00:18:11 -0000 1.8
@@ -516,33 +516,58 @@
* Create, configure, and return a new TCP/IP socket connector
* based on the specified properties.
*
- * @param address InetAddress to listen to, or <code>null</code>
- * to listen on all address on this server
+ * @param address InetAddress to bind to, or <code>null</code> if the
+ * connector is supposed to bind to all addresses on this server
* @param port Port number to listen to
- * @param secure Should this port be SSL-enabled?
+ * @param secure true if the generated connector is supposed to be
+ * SSL-enabled, and false otherwise
*/
public Connector createConnector(InetAddress address, int port,
boolean secure) {
+ return createConnector(address != null? address.toString() : null,
+ port, secure);
+ }
- if( log.isDebugEnabled() )
- log.debug("Creating connector for address='" +
- ((address == null) ? "ALL" : address.getHostAddress()) +
- "' port='" + port + "' secure='" + secure + "'");
-
+ public Connector createConnector(String address, int port,
+ boolean secure) {
String protocol = "http";
if (secure) {
protocol = "https";
}
return createConnector(address, port, protocol);
-
}
public Connector createConnector(InetAddress address, int port,
String protocol) {
+ return createConnector(address != null? address.toString() : null,
+ port, protocol);
+ }
+
+ public Connector createConnector(String address, int port,
+ String protocol) {
Connector connector = null;
+
+ if (address != null) {
+ /*
+ * InetAddress.toString() returns a string of the form
+ * "<hostname>/<literal_IP>". Get the latter part, so that the
+ * address can be parsed (back) into an InetAddress using
+ * InetAddress.getByName().
+ */
+ int index = address.indexOf('/');
+ if (index != -1) {
+ address = address.substring(index + 1);
+ }
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Creating connector for address='" +
+ ((address == null) ? "ALL" : address) +
+ "' port='" + port + "' protocol='" + protocol + "'");
+ }
try {
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org