[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: UnwrapValueUnitTestCase.testCollectionUnwrap failure on

adrian@jboss.org do-not-reply at jboss.com
Thu Nov 20 12:21:24 EST 2008


"alesj" wrote : "adrian at jboss.org" wrote : 
  |   | Let's go with that, but we need to do so extra work to see whether all this 
  |   | caching is (still) effective.
  |   | 
  | But won't this interfere with this:
  | "adrian at jboss.org" wrote : 
  |   | Also I think it will cause a memory leak.
  |   | 
  |   | You effectively have:
  |   | 
  |   |   | WeakValueHashMap<ClassInfo, BeanInfo>	
  |   |   | 
  |   | but the ClassInfo could itself get a hard reference on the BeanInfo
  |   | via one of its "attachments", e.g. the caching of SchemaBindings in jbossxb
  |   | against the TypeInfo.
  |   | 
  | 

I assume you're using a WeakHashMap<ClassInfo, Map>
not a WeakValueHashMap as originally proposed?
The ClassInfo reference is now weak.

anonymous wrote : If not, I'll change it + add some caching tests. :-)

Test the contract not the implemenation details. ;-)
Otherwise, you'll only have to rewrite the tests when you change the caching alogrithm
or some other detail in future - which kind of makes them pointless.

See my earlier printCollection code. This tests the contract and would be
a valid test with or without caching. 
Without caching, it would just be that the Bean/ClassInfo instances
are different == (but equivalent .equals) at each stage.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4190981#4190981

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4190981



More information about the jboss-dev-forums mailing list