adding class resolver with disabled cache, fixing unit tests

This commit is contained in:
alepar 2011-11-23 02:57:32 +04:00
parent 7e6d07afaf
commit cdbaeb86b0
2 changed files with 10 additions and 2 deletions

View File

@ -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();
}
}

View File

@ -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());
}