[jboss-remoting-commits] JBoss Remoting SVN: r3771 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Wed Mar 26 01:03:08 EDT 2008


Author: ron.sigal at jboss.com
Date: 2008-03-26 01:03:07 -0400 (Wed, 26 Mar 2008)
New Revision: 3771

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.java
Log:
JBREM-934: Put Class.getMethod() in AccessController.doPrivileged() call.

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.java	2008-03-26 04:36:21 UTC (rev 3770)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.java	2008-03-26 05:03:07 UTC (rev 3771)
@@ -32,6 +32,7 @@
 import org.jboss.remoting.RemoteClientInvoker;
 import org.jboss.remoting.ServerInvoker;
 import org.jboss.remoting.Version;
+import org.jboss.remoting.loading.ClassByteClassLoader;
 import org.jboss.remoting.marshal.MarshalFactory;
 import org.jboss.remoting.marshal.Marshaller;
 import org.jboss.remoting.marshal.UnMarshaller;
@@ -62,6 +63,9 @@
 import java.net.SocketAddress;
 import java.net.SocketTimeoutException;
 import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -539,7 +543,7 @@
    }
 
 
-   private int getSimulatedTimeout(Map configuration, Map metadata, HttpURLConnection conn)
+   private int getSimulatedTimeout(Map configuration, Map metadata, final HttpURLConnection conn)
    {
       int timeout = -1;
       String connectionTimeout = (String) configuration.get("timeout");
@@ -579,7 +583,22 @@
        */
       try
       {
-         Method setTimeoutMethod = conn.getClass().getMethod("setConnectTimeout", new Class[]{int.class});
+         Method setTimeoutMethod = null;
+         try
+         {
+            setTimeoutMethod = (Method)AccessController.doPrivileged( new PrivilegedExceptionAction()
+            {
+               public Object run() throws Exception
+               {
+                  return conn.getClass().getMethod("setConnectTimeout", new Class[]{int.class});
+               }
+            });
+         }
+         catch (PrivilegedActionException e)
+         {
+             throw (Exception) e.getCause();
+         }
+         
          setTimeoutMethod.invoke(conn, new Object[]{new Integer(timeout)});
          setTimeoutMethod = conn.getClass().getMethod("setReadTimeout", new Class[]{int.class});
          setTimeoutMethod.invoke(conn, new Object[]{new Integer(timeout)});
@@ -599,6 +618,12 @@
          log.error("Error setting http client connection timeout.");
          log.debug(e);
       }
+      catch (Exception e)
+      {
+         // Unexpected.
+         log.error("Unexpected error setting http client connection timeout.");
+         log.debug(e);
+      }
 
       return timeout;
    }




More information about the jboss-remoting-commits mailing list