[jboss-dev] SoftValueHashMap behaves diff then WeakValueHashMap

Dimitris Andreadis dandread at redhat.com
Fri Oct 31 10:25:52 EDT 2008


Were is this needed/used?

Ales Justin wrote:
> jboss-commons-core issue:
> 
> SoftValueHashMap::values doesn't return expected value type:
> 
> e.g.
>    public void testBasicOperations() throws Exception
>    {
>       Map map = createMap();
>       map.put("date1", new Date());
> 
>       Iterable<String> keys = map.keySet();
>       assertIterable(keys, String.class);
>       Iterable<Date> values = map.values();
>       assertIterable(values, Date.class);
>    }
> 
>    protected <T> void assertIterable(Iterable<T> iter, Class<T> clazz)
>    {
>       assertTrue(iter.iterator().hasNext());
>       T next = iter.iterator().next();
>       assertTrue("Next " + next + " is not instance of " + 
> clazz.getName(), clazz.isInstance(next));
>       assertNotNull(next);
>    }
> 
> ---
> 
> junit.framework.AssertionFailedError: Next 
> org.jboss.util.collection.SoftValueHashMap$SoftValueRef at 157f0dc is not 
> instance of java.util.Date
>     at 
> org.jboss.test.util.test.collection.AbstractMapUnitTest.assertIterable(AbstractMapUnitTest.java:33) 
> 
>     at 
> org.jboss.test.util.test.collection.AbstractMapUnitTest.testBasicOperations(AbstractMapUnitTest.java:26) 
> 
> 
> ---
> 
> Where WeakValueHashMap works OK.
> 
> I'll do the fix, Dimitris|Scott can you do a new release then?
> _______________________________________________
> jboss-development mailing list
> jboss-development at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/jboss-development



More information about the jboss-development mailing list