[jboss-remoting-commits] JBoss Remoting SVN: r3848 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport.
jboss-remoting-commits at lists.jboss.org
jboss-remoting-commits at lists.jboss.org
Wed Apr 2 00:18:38 EDT 2008
Author: ron.sigal at jboss.com
Date: 2008-04-02 00:18:38 -0400 (Wed, 02 Apr 2008)
New Revision: 3848
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/Connector.java
Log:
JBREM-934: Put Class.getClassLoader() and InetAddress.getLocalHost() calls in AccessController.doPrivileged() calls.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/Connector.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/Connector.java 2008-04-02 04:15:09 UTC (rev 3847)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/Connector.java 2008-04-02 04:18:38 UTC (rev 3848)
@@ -45,7 +45,9 @@
import javax.net.ServerSocketFactory;
import javax.net.SocketFactory;
import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.HashMap;
@@ -488,7 +490,15 @@
* have to be there. Otherwise, would not be loaded until first client actually reaches the
* target server invoker, where they would otherwise be loaded.
*/
- MarshalFactory.getMarshaller(locator, this.getClass().getClassLoader());
+ ClassLoader classLoader = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return Connector.class.getClassLoader();
+ }
+ });
+
+ MarshalFactory.getMarshaller(locator, classLoader);
Connector marshallerLoader = null;
InvokerLocator loaderLocator = MarshallLoaderFactory.convertLocator(locator);
@@ -553,8 +563,24 @@
String serverBindPort = (String) invokerConfig.get("serverBindPort");
String path = (String) invokerConfig.get("path");
- String host = clientConnectAddress != null ? clientConnectAddress : serverBindAddress != null ? serverBindAddress : InetAddress.getLocalHost().getHostAddress();
- int port = clientConnectPort != null ? Integer.parseInt(clientConnectPort) : serverBindPort != null ? Integer.parseInt(serverBindPort) : PortUtil.findFreePort(serverBindAddress != null ? serverBindAddress : InetAddress.getLocalHost().getHostAddress());
+ String localHostAddress = null;
+ try
+ {
+ localHostAddress = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws UnknownHostException
+ {
+ return InetAddress.getLocalHost().getHostAddress();
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (UnknownHostException) e.getCause();
+ }
+
+ String host = clientConnectAddress != null ? clientConnectAddress : serverBindAddress != null ? serverBindAddress : localHostAddress;
+ int port = clientConnectPort != null ? Integer.parseInt(clientConnectPort) : serverBindPort != null ? Integer.parseInt(serverBindPort) : PortUtil.findFreePort(serverBindAddress != null ? serverBindAddress : localHostAddress);
// finally, let's bild the invoker uri
String tempURI = transport + "://" + host + ":" + port;
@@ -678,12 +704,28 @@
boolean parametersStarted = false;
if (connectHomes == null && homes == null)
{
+ String localHostAddress = null;
+ try
+ {
+ localHostAddress = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws UnknownHostException
+ {
+ return InetAddress.getLocalHost().getHostAddress();
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (UnknownHostException) e.getCause();
+ }
+
// A single home configuration.
String host = clientConnectAddress != null
? clientConnectAddress
: serverBindAddress != null
? serverBindAddress
- : InetAddress.getLocalHost().getHostAddress();
+ : localHostAddress;
int port = clientConnectPort != null
? Integer.parseInt(clientConnectPort)
@@ -691,7 +733,7 @@
? Integer.parseInt(defaultPortString)
: PortUtil.findFreePort(serverBindAddress != null
? serverBindAddress
- : InetAddress.getLocalHost().getHostAddress());
+ : localHostAddress);
tempURI = transport + "://" + host + ":" + port + ((path != null) ? ("/" + path) : "");
}
More information about the jboss-remoting-commits
mailing list