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

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Thu Apr 10 16:16:20 EDT 2008


Author: ron.sigal at jboss.com
Date: 2008-04-10 16:16:18 -0400 (Thu, 10 Apr 2008)
New Revision: 3924

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java
Log:
JBREM-920, JBREM-934: In setup(), moved method.invoke() and Class.forName() into AccessController.doPrivileged() calls.

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java	2008-04-10 13:58:19 UTC (rev 3923)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java	2008-04-10 20:16:18 UTC (rev 3924)
@@ -116,35 +116,27 @@
       boolean apr = false;
       try
       {
-         final String methodName = "initialize";
-         final Class paramTypes[] = new Class[1];
-         paramTypes[0] = String.class;
-         Object paramValues[] = new Object[1];
-         paramValues[0] = null;
-         Method method = null;
-         
-         try
+         AccessController.doPrivileged( new PrivilegedExceptionAction()
          {
-            method = (Method)AccessController.doPrivileged( new PrivilegedExceptionAction()
+            public Object run() throws Exception
             {
-               public Object run() throws Exception
-               {
-                  return Class.forName("org.apache.tomcat.jni.Library").getMethod(methodName, paramTypes);
-               }
-            });
-         }
-         catch (PrivilegedActionException e)
-         {
-             throw (Exception) e.getCause();
-         }
-         
-         method.invoke(null, paramValues);
+               String methodName = "initialize";
+               Class paramTypes[] = new Class[1];
+               paramTypes[0] = String.class;
+               Object paramValues[] = new Object[1];
+               paramValues[0] = null;
+               String className = "org.apache.tomcat.jni.Library";
+               Method method = Class.forName(className).getMethod(methodName, paramTypes);
+               method.invoke(null, paramValues);
+               return null;
+            }
+         });
          apr = true;
       }
-      catch(Throwable t)
+      catch (PrivilegedActionException e)
       {
-         log.trace("",t);
-         // Ignore
+         // Ignore.
+         log.trace("", e.getCause());
       }
 
       // Instantiate the associated HTTP protocol handler
@@ -170,11 +162,19 @@
       Class clazz = null;
       try
       {
-         clazz = Class.forName(protocolHandlerClassName);
+         // The class initialization refers to a System property for logging.
+         final String finalClassName = protocolHandlerClassName;
+         clazz = (Class) AccessController.doPrivileged( new PrivilegedExceptionAction()
+         {
+            public Object run() throws Exception
+            {
+               return Class.forName(finalClassName);
+            }
+         });
       }
-      catch(Exception e)
+      catch (PrivilegedActionException e)
       {
-         log.error("Protocol handler class instatiation failed: protocolHandlerClassName", e);
+         log.error("Protocol handler class instatiation failed: protocolHandlerClassName", e.getCause());
          return;
       }
       




More information about the jboss-remoting-commits mailing list