[jboss-remoting-commits] JBoss Remoting SVN: r3821 - 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 22:58:42 EDT 2008


Author: ron.sigal at jboss.com
Date: 2008-04-01 22:58:42 -0400 (Tue, 01 Apr 2008)
New Revision: 3821

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/Client.java
Log:
JBREM-934: Put Thread.currentThread() in AccessController.doPrivileged() call.

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/Client.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/Client.java	2008-04-02 02:56:49 UTC (rev 3820)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/Client.java	2008-04-02 02:58:42 UTC (rev 3821)
@@ -52,7 +52,12 @@
 import java.io.StreamCorruptedException;
 import java.net.InetAddress;
 import java.net.SocketTimeoutException;
+import java.net.UnknownHostException;
 import java.rmi.MarshalException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -252,7 +257,7 @@
     */
    public Client(InvokerLocator locator, String subsystem, Map configuration) throws Exception
    {
-      this(Thread.currentThread().getContextClassLoader(), locator, subsystem, configuration);
+      this(null, locator, subsystem, configuration);
    }
 
    /**
@@ -270,7 +275,20 @@
    public Client(ClassLoader cl, InvokerLocator locator, String subsystem, Map configuration)
          throws Exception
    {
-      this.classloader = cl;
+      if (cl == null)
+      {
+         this.classloader = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction()
+         {
+            public Object run()
+            {
+               return Thread.currentThread().getContextClassLoader();
+            }
+         });
+      }
+      else
+      {
+         this.classloader = cl;
+      }
       this.locator = locator;
       this.subsystem = subsystem == null ? null : subsystem.toUpperCase();
       if (configuration != null)
@@ -312,7 +330,14 @@
             this.configuration = (Map) in.readObject();
             boolean wasConnected = in.readBoolean();
 
-            this.classloader = Thread.currentThread().getContextClassLoader();
+            this.classloader = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction()
+            {
+               public Object run()
+               {
+                  return Thread.currentThread().getContextClassLoader();
+               }
+            });
+            
             try
             {
                this.invoker = InvokerRegistry.createClientInvoker(locator, configuration);
@@ -916,7 +941,20 @@
                }
                if (host == null)
                {
-                  host = InetAddress.getLocalHost().getHostAddress();
+                  try
+                  {
+                     host = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
+                     {
+                        public Object run() throws UnknownHostException
+                        {
+                           return InetAddress.getLocalHost().getHostAddress();
+                        }
+                     });
+                  }
+                  catch (PrivilegedActionException e)
+                  {
+                     throw (UnknownHostException) e.getCause();
+                  } 
                   metadata.put(CALLBACK_SERVER_HOST, host);
                }
                if (port == -1)




More information about the jboss-remoting-commits mailing list