[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting/transport/rmi ...
Ron Sigal
ron_sigal at yahoo.com
Sun Feb 4 02:38:49 EST 2007
User: rsigal
Date: 07/02/04 02:38:49
Modified: src/main/org/jboss/remoting/transport/rmi Tag: remoting_2_x
RemotingRMIClientSocketFactory.java
Log:
JBREM-697: ComparableHolder uses InetAddress for host name.
Revision Changes Path
No revision
No revision
1.9.4.3 +25 -6 JBossRemoting/src/main/org/jboss/remoting/transport/rmi/RemotingRMIClientSocketFactory.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: RemotingRMIClientSocketFactory.java
===================================================================
RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/transport/rmi/RemotingRMIClientSocketFactory.java,v
retrieving revision 1.9.4.2
retrieving revision 1.9.4.3
diff -u -b -r1.9.4.2 -r1.9.4.3
--- RemotingRMIClientSocketFactory.java 18 Jan 2007 04:46:34 -0000 1.9.4.2
+++ RemotingRMIClientSocketFactory.java 4 Feb 2007 07:38:48 -0000 1.9.4.3
@@ -24,7 +24,9 @@
import java.io.IOException;
import java.io.Serializable;
+import java.net.InetAddress;
import java.net.Socket;
+import java.net.UnknownHostException;
import java.rmi.server.RMIClientSocketFactory;
import java.util.HashMap;
import java.util.Map;
@@ -64,7 +66,7 @@
* with localhost will allow the retrieval of objects bound to localhost.
*
* @author <a href="mailto:r.sigal at computer.org">Ron Sigal</a>
- * @version $Revision: 1.9.4.2 $
+ * @version $Revision: 1.9.4.3 $
* <p/>
* Copyright (c) 2005
* </p>
@@ -157,11 +159,19 @@
public Socket createSocket(String host, int port) throws IOException
{
// If invokerLocator isn't in configMaps, an RMICLientInvoker has not been created
- // yet. This call was probably made by an RMI thread, and is premature.
+ // yet. This call was probably made by an RMI thread, and is premature. Best attempt
+ // is to return a vanilla socket.
+
+ // Note: the previous observation might be incorrect. The phenomenon of missing
+ // entries in configMaps might simply have been an error in the definition of
+ // ComparableHolder.equals. See JBREM-697.
ComparableHolder holder = new ComparableHolder(invokerLocator);
if (!configMaps.containsKey(holder))
- return null;
-
+ {
+ log.warn("unrecognized invoker locator: " + invokerLocator);
+ log.warn("unable to retrieve socket factory: returning plain socket");
+ return new Socket(host, port);
+ }
socketFactory = retrieveSocketFactory(holder);
String effectiveHost = hostName != null ? hostName : host;
@@ -235,14 +245,23 @@
protected static class ComparableHolder
{
private String protocol;
- private String host;
+ private InetAddress host;
private int port;
private int hashCode;
public ComparableHolder(InvokerLocator invokerLocator)
{
protocol = invokerLocator.getProtocol().toLowerCase();
- host = invokerLocator.getHost();
+
+ try
+ {
+ host = InetAddress.getByName(invokerLocator.getHost());
+ }
+ catch (UnknownHostException e)
+ {
+ log.error("unable to resolve host: " + invokerLocator.getHost());
+ }
+
port = invokerLocator.getPort();
hashCode = protocol.hashCode() * host.hashCode() * port;
}
More information about the jboss-cvs-commits
mailing list