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

alesj do-not-reply at jboss.com
Thu Nov 20 07:31:01 EST 2008


"alesj" wrote : 
  | This looks like caching issue.
  | 
Yup, caching:
 - https://jira.jboss.org/jira/browse/JBREFLECT-7

This is what's actually going on:
(code is from WeakTypeCache)

1) checkCollection(new HashSet(), getType("Integer", Set.class), i1, i2);


  |    protected void put(ParameterizedType type, T result)
  |    {
  |       Class<?> rawType = (Class<?>) type.getRawType();
  |       ClassLoader cl = SecurityActions.getClassLoader(rawType);
  |       Map<String, T> classLoaderCache = getClassLoaderCache(cl);
  | 
  |       synchronized (classLoaderCache)
  |       {
  |          // TODO JBMICROCONT-131 something better than toString()?
  |          classLoaderCache.put(type.toString(), result);
  |       }
  |    }
  | 

interface java.util.Set + result are now part of cache

2) checkCollection(new HashSet(), getType("Enum", Set.class), one, two, three, one);


  |    protected T peek(ParameterizedType type)
  |    {
  |       Class<?> rawType = (Class<?>) type.getRawType();
  |       ClassLoader cl = SecurityActions.getClassLoader(rawType);
  |       Map<String, T> classLoaderCache = getClassLoaderCache(cl);
  |       
  |       synchronized (classLoaderCache)
  |       {
  |          return classLoaderCache.get(type.toString());
  |       }
  |    }
  | 

And you're 'unlucky' that weak value is still cached under "interface java.util.Set".
Hence you get integer Set --> Integer component type.

So, JBMAN-38 is purely JBREFLECT-7's result.
Who's gonna bite into JBREFLECT-7, Adrian? :-)

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

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



More information about the jboss-dev-forums mailing list