This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
ProxyLookup (when assertions are enabled) guards its internals by wrapping its internal results Map with Collections.synchronizedMap. Unluckily, it does it even during internal operations as a result of a change in delegates, so the chain of Collections.synchronizedMap grows and slows down the lookup considerably. It can also lead to stack overflows. The problem seems to be inside RealInternalData.getResults() The test follows: public void testFrequentSwitching() { Object o1 = new Object(); Object o2 = new Object(); String s1 = new String("foo"); String s2 = new String("bar"); Lookup l1 = Lookups.fixed(o1, s1); Lookup l2 = Lookups.fixed(o2, s2); ProxyLookup lookup = new ProxyLookup (new Lookup[0]); Lookup.Result<Object> res1 = lookup.lookupResult(Object.class); Lookup.Result<String> res2 = lookup.lookupResult(String.class); for (int i=0; i<100; i++) { lookup.setLookups(l1); lookup.setLookups(l2); } assertSize("Lookup has grown too much", 1500, lookup); }
core-main#47bc964ce54e
Created attachment 100128 [details] Sample application which leads to StackOverflow when using ProxyLookup This small application is based on http://blogs.sun.com/geertjan/entry/lookup_example.
Integrated into 'main-golden', will be available in build *201006170001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/47bc964ce54e User: Jaroslav Tulach <jtulach@netbeans.org> Log: #187642: Don't wrap unmodifiableMap in another unmodifiableMap