[jboss-remoting-commits] JBoss Remoting SVN: r3717 - remoting2/branches/2.x/src/main/org/jboss/remoting/loading.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Fri Mar 21 01:04:20 EDT 2008


Author: ron.sigal at jboss.com
Date: 2008-03-21 01:04:18 -0400 (Fri, 21 Mar 2008)
New Revision: 3717

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/loading/ObjectInputStreamWithClassLoader.java
Log:
JBREM-934: Put Class.class.getDeclaredMethod() in AccessController.doPrivileged() call.

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/loading/ObjectInputStreamWithClassLoader.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/loading/ObjectInputStreamWithClassLoader.java	2008-03-21 04:53:35 UTC (rev 3716)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/loading/ObjectInputStreamWithClassLoader.java	2008-03-21 05:04:18 UTC (rev 3717)
@@ -22,13 +22,18 @@
 
 package org.jboss.remoting.loading;
 
+import java.beans.IntrospectionException;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.StreamCorruptedException;
 import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.util.HashMap;
 
 import org.jboss.logging.Logger;
+import org.jboss.util.propertyeditor.PropertyEditors;
 
 
 /**
@@ -40,25 +45,40 @@
  */
 public class ObjectInputStreamWithClassLoader extends ObjectInputStream
 {
-    
+
    protected static Method clearMethod;
-   
+
    protected static final Logger log = Logger.getLogger(ObjectInputStreamWithClassLoader.class);
-   
-   
-   
+
+
+
    static
    {
-      try {
-        clearMethod = ObjectInputStream.class.getDeclaredMethod("clear", new Class[]{});
-        clearMethod.setAccessible(true);
+      try
+      {
+         try {
+            clearMethod = (Method) AccessController.doPrivileged( new PrivilegedExceptionAction()
+            {
+               public Object run() throws SecurityException, NoSuchMethodException
+               {
+                  return ObjectInputStream.class.getDeclaredMethod("clear", new Class[]{});
+               }
+            });
+         }
+         catch (PrivilegedActionException e)
+         {
+            throw (NoSuchMethodException) e.getCause();
+         }
+
+         clearMethod.setAccessible(true);
+         
       } catch (SecurityException e) {
-        log.error(e.getMessage(), e);
-       } catch (NoSuchMethodException e) {
-        log.error(e.getMessage(), e);
-    }
+         log.error(e.getMessage(), e);
+      } catch (NoSuchMethodException e) {
+         log.error(e.getMessage(), e);
+      }
    }
-   
+
    private ClassLoader cl;
 
    // EJBTHREE-440




More information about the jboss-remoting-commits mailing list