升级Google Collections后弱引用测试失败

goto-array 发布于 2013/09/18 22:37
阅读 730
收藏 0

同样的测试代码,原本用Google Collections 1.0测试通过,升级到Guava 14.0便不行了。

    @Test
	public void testWeakRef() throws Exception{
		MapMaker maker = new MapMaker();
		ConcurrentMap<Object, Object> map = maker
			.weakKeys()
			.weakValues()
			.<Object, Object>makeMap();
		map.put(new Object(), new int[]{1,2,3});
		System.out.println(map.size());
		System.gc(); TimeUnit.SECONDS.sleep(1L);
		System.out.println(map.size());
		Assert.assertTrue(map.isEmpty());
		
		this.createData(map);
		this.testOutOfMemory(map);
		Assert.assertTrue(map.isEmpty());
	}

尝试改用com.google.common.cache.CacheBuilder依然无效,都卡在第一个断言,求解?




加载中
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部