[jboss-remoting-commits] JBoss Remoting SVN: r3824 - remoting2/branches/2.x/src/main/org/jboss/remoting.
jboss-remoting-commits at lists.jboss.org
jboss-remoting-commits at lists.jboss.org
Tue Apr 1 23:05:55 EDT 2008
Author: ron.sigal at jboss.com
Date: 2008-04-01 23:05:55 -0400 (Tue, 01 Apr 2008)
New Revision: 3824
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java
Log:
JBREM-934: Put InetAddress.getLocalHost() in AccessController.doPrivileged() call.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java 2008-04-02 03:04:10 UTC (rev 3823)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java 2008-04-02 03:05:55 UTC (rev 3824)
@@ -57,6 +57,7 @@
import java.net.MalformedURLException;
import java.net.UnknownHostException;
import java.security.AccessController;
+import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.Collection;
@@ -1135,16 +1136,30 @@
}
// If no bind address(es) found, try the old way.
- String locatorHost = locator.getHost();
+ final String locatorHost = locator.getHost();
InetAddress addr = null;
- if(locatorHost != null)
+ try
{
- addr = InetAddress.getByName(locator.getHost());
+ addr = (InetAddress)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws UnknownHostException
+ {
+ if(locatorHost != null)
+ {
+ return InetAddress.getByName(locator.getHost());
+ }
+ else
+ {
+ return InetAddress.getLocalHost();
+ }
+ }
+ });
}
- else
+ catch (PrivilegedActionException e)
{
- addr = InetAddress.getLocalHost();
+ throw (UnknownHostException) e.getCause();
}
+
int port = locator.getPort();
if(port <= 0)
{
@@ -1159,7 +1174,20 @@
if(clientConnectAddress != null)
{
// can't use uri address, as is for client only
- serverBindAddress = InetAddress.getLocalHost().getHostAddress();
+ try
+ {
+ serverBindAddress = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws UnknownHostException
+ {
+ return InetAddress.getLocalHost().getHostAddress();
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (UnknownHostException) e.getCause();
+ }
}
else
{
@@ -1269,41 +1297,30 @@
if(host == null || InvokerLocator.ANY.equals(host))
{
// now need to get some external bindable address
- boolean byHost = true;
- String bindByHost = "True";
-
try
{
- bindByHost = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ newHost = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
{
public Object run() throws Exception
{
- return System.getProperty(InvokerLocator.BIND_BY_HOST, "True");
+ String bindByHost = System.getProperty(InvokerLocator.BIND_BY_HOST, "True");
+ boolean byHost = Boolean.valueOf(bindByHost).booleanValue();
+ if(byHost)
+ {
+ return InetAddress.getLocalHost().getHostName();
+ }
+ else
+ {
+ return InetAddress.getLocalHost().getHostAddress();
+ }
}
});
}
- catch (Exception e)
+ catch (PrivilegedActionException e)
{
- log.debug("error", e.getCause());
+ log.debug("Could not get host by name or address.", e.getCause());
}
-
- byHost = Boolean.valueOf(bindByHost).booleanValue();
-
- try
- {
- if(byHost)
- {
- newHost = InetAddress.getLocalHost().getHostName();
- }
- else
- {
- newHost = InetAddress.getLocalHost().getHostAddress();
- }
- }
- catch (UnknownHostException e)
- {
- log.debug("Could not get host by name or address.", e);
- }
+
if(newHost == null)
{
// now what? step through network interfaces?
More information about the jboss-remoting-commits
mailing list