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

The following examples show how to use java.util.concurrent.ConcurrentMap#containsValue() . These examples are extracted from open source projects. 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
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 Project: caffeine   File: ConcurrentHashMapTest.java    License: 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) {}
}