Java Code Examples for java.util.concurrent.ConcurrentMap#containsValue()

The following examples show how to use java.util.concurrent.ConcurrentMap#containsValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Bug2898106a.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
static Semaphore getLock(ConcurrentMap<String, Semaphore> locks2, String key) {
    Semaphore lock = locks2.get(key);
    if (lock == null) {
        Semaphore newLock = new Semaphore(1, true);
        locks2.get(null);
        locks2.put(null, null);
        locks2.remove(null);
        locks2.containsKey(null);
        locks2.containsValue(null);
        locks2.putIfAbsent(null, null);
        locks2.remove(null, null);
        locks2.replace(null, null);
        locks2.replace(null, null, null);
        lock = locks2.putIfAbsent(key, lock);
        // value, being null, will *always* throw NullPointerException
        if (lock == null)
            lock = newLock;
    }
    return lock;
}
 
Example 2
Source File: ConcurrentHashMapTest.java    From caffeine with Apache License 2.0 5 votes vote down vote up
/**
 * containsValue(null) throws NPE
 */
public void testContainsValue_NullPointerException() {
    ConcurrentMap c = map();
    try {
        c.containsValue(null);
        shouldThrow();
    } catch (NullPointerException success) {}
}