[concurrency-interest] Bug in CustomConcurrentHashMap.KeySet.intern()

Manuel Dominguez Sarmiento mads at renxo.com
Mon Jun 29 16:14:32 EDT 2009


Hi,

I found that CustomConcurrentHashMap.KeySet.intern() was the perfect fit 
for the object interning need we're having with a current project. 
However the implementation of this method fails returning null when a 
new object that is still not in the Map/Set is first interned. Currently 
the method implementation is the following:

        public K intern(K e) {
            return cchm.doPut(e, e, true);
        }

However, doPut() returns null when a key is first added to the map. It 
could be easily fixed as follows:

        public K intern(K e) {
            K oldElement = cchm.doPut(e, e, true);
            return (oldElement != null) ? oldElement : e;
        }

BTW, how stable is this preview release for production use? Any caveats?

Thanks,

-- 
Ing. Manuel Dominguez Sarmiento
Director General
Renxo S.A.
e-mail:	mads at renxo.com
Phone:	+54 11 4719 6806, ext. 104




More information about the Concurrency-interest mailing list