From cdbaeb86b07580858f6006207c5313dc573591fe Mon Sep 17 00:00:00 2001 From: alepar Date: Wed, 23 Nov 2011 02:57:32 +0400 Subject: [PATCH] adding class resolver with disabled cache, fixing unit tests --- .../handler/codec/serialization/ClassResolvers.java | 10 +++++++++- .../serialization/CompactObjectSerializationTest.java | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jboss/netty/handler/codec/serialization/ClassResolvers.java b/src/main/java/org/jboss/netty/handler/codec/serialization/ClassResolvers.java index 4df8e3d3bc..cbc4d1db15 100644 --- a/src/main/java/org/jboss/netty/handler/codec/serialization/ClassResolvers.java +++ b/src/main/java/org/jboss/netty/handler/codec/serialization/ClassResolvers.java @@ -6,6 +6,15 @@ import java.util.concurrent.ConcurrentHashMap; public class ClassResolvers { + /** + * cache disabled + * @param classLoader - specific classLoader to use, or null if you want to revert to default + * @return new instance of class resolver + */ + public static ClassResolver cacheDisabled(ClassLoader classLoader) { + return new ClassloaderClassResolver(defaultClassLoader(classLoader)); + } + /** * non-agressive non-concurrent cache * good for non-shared default cache @@ -62,5 +71,4 @@ public class ClassResolvers { return ClassResolvers.class.getClassLoader(); } - } diff --git a/src/test/java/org/jboss/netty/handler/codec/serialization/CompactObjectSerializationTest.java b/src/test/java/org/jboss/netty/handler/codec/serialization/CompactObjectSerializationTest.java index 0db5000c7c..b233981ddb 100644 --- a/src/test/java/org/jboss/netty/handler/codec/serialization/CompactObjectSerializationTest.java +++ b/src/test/java/org/jboss/netty/handler/codec/serialization/CompactObjectSerializationTest.java @@ -32,7 +32,7 @@ public class CompactObjectSerializationTest { PipedOutputStream pipeOut = new PipedOutputStream(); PipedInputStream pipeIn = new PipedInputStream(pipeOut); CompactObjectOutputStream out = new CompactObjectOutputStream(pipeOut); - CompactObjectInputStream in = new CompactObjectInputStream(pipeIn); + CompactObjectInputStream in = new CompactObjectInputStream(pipeIn, ClassResolvers.cacheDisabled(null)); out.writeObject(List.class); Assert.assertSame(List.class, in.readObject()); }