This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

UnicastConnectionManager


This bug has taken me three solid days to find.  :-(

The symptom was that all the JBoss tests failed with "connection
refused".  A trace on the interface revealed that the listener,
explicitly set by the user to "localhost", was listening on 127.0.0.1,
but the client connection was attempting to connect to 10.0.0.13, the
IP address of this box.

A very long trawl through RMI revealed the real bug, which is that the
default UnicastConnectionManager sets its serverName to
UnicastConnectionManager.localhost, which is initialized by

    localhost = InetAddress.getLocalHost().getHostAddress();

This is the external address of the box, not the loopback address.

I'd be grateful if someone who really understands RMI could comment on
this.  I'm pretty sure it's right, given that this seems to fix the
JBoss tests connection failure...

Andrew.


2007-04-17  Andrew Haley  <aph@redhat.com>

	* gnu/java/rmi/server/UnicastConnectionManager.java
	(UnicastConnectionManager(int port, RMIServerSocketFactory)):
	Listen on "localhost", not localhost.

Index: gnu/java/rmi/server/UnicastConnectionManager.java
===================================================================
--- gnu/java/rmi/server/UnicastConnectionManager.java	(revision 123861)
+++ gnu/java/rmi/server/UnicastConnectionManager.java	(working copy)
@@ -181,7 +181,13 @@
 		serverPort = 0;
 		throw new java.rmi.server.ExportException("can not create Server Socket on port " + port,ioex);
 	}
-	serverName = localhost;
+	// Note that for compatibility the serverName is "localhost",
+	// not UnicastConnectionManager.localhost, which is the name
+	// of the local box.  A server listening on localhost:port is
+	// listening on the loopback interface, 127.0.0.1, but
+	// UnicastConnectionManager.localhost is an externally
+	// accessible IP address.
+	serverName = "localhost";
 	serverFactory = ssf;
 	clientFactory = null;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]