[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting/loading ...

Ron Sigal ron_sigal at yahoo.com
Tue Apr 24 03:03:17 EDT 2007


  User: rsigal  
  Date: 07/04/24 03:03:17

  Modified:    src/main/org/jboss/remoting/loading  Tag: remoting_2_2_0_GA
                        ObjectInputStreamWithClassLoader.java
  Log:
  JBREM-739:  Fix for java serialization leak.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.4.4.1.4.1 +37 -2     JBossRemoting/src/main/org/jboss/remoting/loading/ObjectInputStreamWithClassLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ObjectInputStreamWithClassLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/loading/ObjectInputStreamWithClassLoader.java,v
  retrieving revision 1.4.4.1
  retrieving revision 1.4.4.1.4.1
  diff -u -b -r1.4.4.1 -r1.4.4.1.4.1
  --- ObjectInputStreamWithClassLoader.java	11 Jan 2007 20:34:49 -0000	1.4.4.1
  +++ ObjectInputStreamWithClassLoader.java	24 Apr 2007 07:03:17 -0000	1.4.4.1.4.1
  @@ -25,18 +25,40 @@
   import java.io.IOException;
   import java.io.ObjectInputStream;
   import java.io.StreamCorruptedException;
  +import java.lang.reflect.Method;
   import java.util.HashMap;
   
  +import org.jboss.logging.Logger;
  +
   
   /**
    * ObjectInputStreamWithClassLoader
    *
    * @author <a href="mailto:jhaynie at vocalocity.net">Jeff Haynie</a>
    * @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
  - * @version $Revision: 1.4.4.1 $
  + * @version $Revision: 1.4.4.1.4.1 $
    */
   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);
  +      } catch (SecurityException e) {
  +        log.error(e.getMessage(), e);
  +       } catch (NoSuchMethodException e) {
  +        log.error(e.getMessage(), e);
  +    }
  +   }
  +   
      private ClassLoader cl;
   
      // EJBTHREE-440
  @@ -96,6 +118,19 @@
         return cl;
      }
   
  +   public void clearCache()
  +   {
  +       try
  +       {
  +           clearMethod.invoke(this, new Object[]{});
  +       }
  +       catch (Throwable e)
  +       {
  +           log.error(e.getMessage(), e);
  +       }
  +       
  +   }
  +
      /**
       * Load the local class equivalent of the specified stream class description.
       * <p/>
  
  
  



More information about the jboss-cvs-commits mailing list