From: Manik S. <msu...@jb...> - 2006-04-30 11:16:38
|
User: msurtani Date: 06/04/30 07:16:37 Modified: src/org/jboss/cache/marshall EnhancedTreeCacheMarshaller.java Log: Fix for using context class loaders with JBoss Serialization Revision Changes Path 1.15 +19 -16 JBossCache/src/org/jboss/cache/marshall/EnhancedTreeCacheMarshaller.java (In the diff below, changes in quantity of whitespace are not shown.) Index: EnhancedTreeCacheMarshaller.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/marshall/EnhancedTreeCacheMarshaller.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -b -r1.14 -r1.15 --- EnhancedTreeCacheMarshaller.java 30 Apr 2006 00:51:00 -0000 1.14 +++ EnhancedTreeCacheMarshaller.java 30 Apr 2006 11:16:37 -0000 1.15 @@ -6,17 +6,6 @@ */ package org.jboss.cache.marshall; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.cache.CacheException; @@ -29,6 +18,17 @@ import org.jgroups.blocks.MethodCall; import org.jgroups.stack.IpAddress; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + /** * An enhanced marshaller for RPC calls between TreeCache instances. * @@ -377,11 +377,19 @@ try { currentThread.setContextClassLoader(loader); + if (in instanceof JBossObjectInputStream) + { + ((JBossObjectInputStream)in).setClassLoader(loader); + } return unmarshallObject(in); } finally { currentThread.setContextClassLoader(old); + if (in instanceof JBossObjectInputStream) + { + ((JBossObjectInputStream)in).setClassLoader(old); + } } } } @@ -394,11 +402,6 @@ case MAGICNUMBER_NULL: return null; case MAGICNUMBER_SERIALIZABLE: - if (in instanceof JBossObjectInputStream) - { - System.out.println("Setting classLoader"); - ((JBossObjectInputStream)in).setClassLoader(Thread.currentThread().getContextClassLoader()); - } return in.readObject(); case MAGICNUMBER_METHODCALL: return unmarshallMethodCall(in); |