[jboss-dev] SoftValueHashMap behaves diff then WeakValueHashMap

Ales Justin ales.justin at gmail.com
Fri Oct 31 08:53:11 EDT 2008


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?



More information about the jboss-development mailing list