Commit 774c187e authored by Alexander Kass's avatar Alexander Kass
Browse files

ConcurrentFactoryMap fix nullability issues

parent e62585f6
Branches unavailable Tags unavailable
No related merge requests found
Showing with 10 additions and 11 deletions
+10 -11
......@@ -43,10 +43,9 @@ public class MapInvariantsTestSuite {
Assert.assertEquals(1, map.size());
Assert.assertEquals("Removed val differs", val, map.remove(null));
Assert.assertEquals(0, map.size());
//todo: ConcurrentMap: strange nullability of remove(K, V), replace(K, V), replace(K, V, V)
//map.put(null, val);
//Assert.assertTrue("Removed val differs", map.remove(null, val));
//Assert.assertEquals(0, map.size());
map.put(null, val);
Assert.assertTrue("Removed val differs", map.remove(null, val));
Assert.assertEquals(0, map.size());
}
@Test
......
......@@ -175,23 +175,23 @@ public abstract class ConcurrentFactoryMap<K,V> implements ConcurrentMap<K,V> {
}
@Override
public V putIfAbsent(@NotNull K key, V value) {
return myMap.putIfAbsent(key, ConcurrentFactoryMap.<V>notNull(value));
public V putIfAbsent(K key, V value) {
return nullize(myMap.putIfAbsent(ConcurrentFactoryMap.<K>notNull(key), ConcurrentFactoryMap.<V>notNull(value)));
}
@Override
public boolean remove(@NotNull Object key, Object value) {
return myMap.remove(key, notNull(value));
public boolean remove(Object key, Object value) {
return myMap.remove(ConcurrentFactoryMap.<K>notNull(key), ConcurrentFactoryMap.<V>notNull(value));
}
@Override
public boolean replace(@NotNull K key, @NotNull V oldValue, @NotNull V newValue) {
return myMap.replace(key, oldValue, newValue);
public boolean replace(K key, V oldValue, V newValue) {
return myMap.replace(ConcurrentFactoryMap.<K>notNull(key), ConcurrentFactoryMap.<V>notNull(oldValue), ConcurrentFactoryMap.<V>notNull(newValue));
}
@Override
public V replace(@NotNull K key, @NotNull V value) {
return myMap.replace(key, value);
return nullize(myMap.replace(ConcurrentFactoryMap.<K>notNull(key), ConcurrentFactoryMap.<V>notNull(value)));
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment