Skip to content

Commit b08120c

Browse files
committed
pr review
1 parent a6ad53f commit b08120c

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/cache/weaklockfree/AbstractWeakConcurrentMap.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,11 @@ public int hashCode() {
333333
}
334334

335335
@Override
336-
public boolean equals(@Nullable Object other) {
336+
public boolean equals(Object other) {
337337
if (other instanceof WeakKey<?>) {
338338
return ((WeakKey<?>) other).get() == get();
339339
} else {
340-
return requireNonNull(other).equals(this);
340+
return other.equals(this);
341341
}
342342
}
343343

@@ -379,11 +379,12 @@ public boolean hasNext() {
379379

380380
@Override
381381
public Map.Entry<K, V> next() {
382-
if (nextKey == null) {
382+
K key = nextKey;
383+
if (key == null) {
383384
throw new NoSuchElementException();
384385
}
385386
try {
386-
return new SimpleEntry(requireNonNull(nextKey), requireNonNull(nextEntry));
387+
return new SimpleEntry(key, requireNonNull(nextEntry));
387388
} finally {
388389
findNext();
389390
}

instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/cache/weaklockfree/WeakConcurrentMap.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525

2626
package io.opentelemetry.instrumentation.api.internal.cache.weaklockfree;
2727

28-
import static java.util.Objects.requireNonNull;
29-
3028
import java.util.Iterator;
3129
import java.util.Map;
3230
import java.util.concurrent.ConcurrentHashMap;
@@ -161,11 +159,11 @@ void reset() {
161159
}
162160

163161
@Override
164-
public boolean equals(@Nullable Object other) {
162+
public boolean equals(Object other) {
165163
if (other instanceof WeakConcurrentMap.LookupKey<?>) {
166164
return ((LookupKey<?>) other).key == key;
167165
} else {
168-
return ((AbstractWeakConcurrentMap.WeakKey<?>) requireNonNull(other)).get() == key;
166+
return ((AbstractWeakConcurrentMap.WeakKey<?>) other).get() == key;
169167
}
170168
}
171169

0 commit comments

Comments
 (0)