Re: Relieving some ClassLoader contention in PreferredClassProvider

Gregg Wonderly <[email protected]>
Newsgroups gmane.comp.java.sun.jini
Message-ID <[email protected]>
Bob Scheifler wrote:
>> I found that in my implementation, I am experiencing classloader
>> inequalities due to the equality not working reliably.
>
>
>> I brought this up on the concurrency-interest mailing list, because
>> ConcurrentHashMap.putIfAbsent() is randomly returning the wrong value.
>
>
> Are you saying you think the problem is in URL or ConcurrentHashMap, or
> both?

I'm not sure yet because I haven't been able to spend time on finding the exact
cause.  The only thing that I do know, is that

ConcurrentHashmap map;
synchronized( map ) {
        Object fut = map.get(key);
        if( fut == null ) {
                map.put( key, newfut );
                fut = newfut;
        }
}

worked differently than

fut = map.putIfAbsent( key, newfut );

based on logging that I put around these two blocks in my initial evaluation of
some ClassCastException traces comming out at random moments when my (too short)
ServiceRegistrar.notify() lease would expire and I'd renew the notify in a
background thread.

The synchronized block changed the logging output to indicate that the right
entry was in the map after the block based on the information shown inside of
the synchronzied block, but before the get/put pair were executed.

The putIfAbsent call, without any synchronization around the logging and the
putIfAbsent call would sometimes indicate in a map.toString() list that an entry
was present and putIfAbsent() did not see it.

Gregg Wonderly

--------------------------------------------------------------------------
Getting Started:     http://www.jini.org/wiki/Category:Getting_Started
Community Web Site:  http://jini.org
jini-users Archive:  http://archives.java.sun.com/archives/jini-users.html
Unsubscribing:       email "signoff JINI-USERS"  to [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.