This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-collections.git
The following commit(s) were added to refs/heads/master by this push: new d24d7a83a Use Objects.requireNonNull() d24d7a83a is described below commit d24d7a83aea5f85f21a47a25b0901b6c757598d1 Author: Gary D. Gregory <garydgreg...@gmail.com> AuthorDate: Thu Dec 26 14:05:47 2024 -0500 Use Objects.requireNonNull() --- .../map/ConcurrentReferenceHashMap.java | 26 +++++++--------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/apache/commons/collections4/map/ConcurrentReferenceHashMap.java b/src/main/java/org/apache/commons/collections4/map/ConcurrentReferenceHashMap.java index bd47592f8..232c41bc0 100644 --- a/src/main/java/org/apache/commons/collections4/map/ConcurrentReferenceHashMap.java +++ b/src/main/java/org/apache/commons/collections4/map/ConcurrentReferenceHashMap.java @@ -1303,9 +1303,7 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen */ @Override public V setValue(final V value) { - if (value == null) { - throw new NullPointerException(); - } + Objects.requireNonNull(value, "value"); final V v = super.setValue(value); ConcurrentReferenceHashMap.this.put(getKey(), value); return v; @@ -1553,9 +1551,7 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen */ @Override public boolean containsValue(final Object value) { - if (value == null) { - throw new NullPointerException(); - } + Objects.requireNonNull(value, "value"); // See explanation of modCount use above final Segment<K, V>[] segments = this.segments; final int[] mc = new int[segments.length]; @@ -1715,9 +1711,8 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen */ @Override public V put(final K key, final V value) { - if (key == null || value == null) { - throw new NullPointerException(); - } + Objects.requireNonNull(key, "key"); + Objects.requireNonNull(value, "value"); final int hash = hashOf(key); return segmentFor(hash).put(key, hash, value, null, false); } @@ -1743,9 +1738,7 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen */ @Override public V putIfAbsent(final K key, final V value) { - if (value == null) { - throw new NullPointerException(); - } + Objects.requireNonNull(value, "value"); final int hash = hashOf(key); return segmentFor(hash).put(key, hash, value, null, true); } @@ -1785,9 +1778,7 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen */ @Override public V replace(final K key, final V value) { - if (value == null) { - throw new NullPointerException(); - } + Objects.requireNonNull(value, "value"); final int hash = hashOf(key); return segmentFor(hash).replace(key, hash, value); } @@ -1799,9 +1790,8 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen */ @Override public boolean replace(final K key, final V oldValue, final V newValue) { - if (oldValue == null || newValue == null) { - throw new NullPointerException(); - } + Objects.requireNonNull(oldValue, "oldValue"); + Objects.requireNonNull(newValue, "newValue"); final int hash = hashOf(key); return segmentFor(hash).replace(key, hash, oldValue, newValue); }