diff --git a/protocol/src/main/java/com/zfoo/protocol/collection/concurrent/CopyOnWriteHashMapLongObject.java b/protocol/src/main/java/com/zfoo/protocol/collection/concurrent/CopyOnWriteHashMapLongObject.java index ce65f28b..522ccb91 100644 --- a/protocol/src/main/java/com/zfoo/protocol/collection/concurrent/CopyOnWriteHashMapLongObject.java +++ b/protocol/src/main/java/com/zfoo/protocol/collection/concurrent/CopyOnWriteHashMapLongObject.java @@ -70,12 +70,16 @@ public class CopyOnWriteHashMapLongObject implements Map { return map.get(key); } - public V getPrimitive(long key) { + public V get(long key) { return map.get(key); } @Override public V put(Long key, V value) { + return put(key.longValue(), value); + } + + public V put(long key, V value) { lock.lock(); try { var newMap = newCopyMap(); @@ -89,6 +93,10 @@ public class CopyOnWriteHashMapLongObject implements Map { @Override public V remove(Object key) { + return remove(((Long) key).longValue()); + } + + public V remove(long key) { lock.lock(); try { var newMap = newCopyMap(); diff --git a/protocol/src/main/java/com/zfoo/protocol/util/ThreadUtils.java b/protocol/src/main/java/com/zfoo/protocol/util/ThreadUtils.java index 0da22fd8..525f838a 100644 --- a/protocol/src/main/java/com/zfoo/protocol/util/ThreadUtils.java +++ b/protocol/src/main/java/com/zfoo/protocol/util/ThreadUtils.java @@ -117,7 +117,7 @@ public abstract class ThreadUtils { } public static Executor executorByThreadId(long threadId) { - var threadExecutor = threadExecutorMap.getPrimitive(threadId); + var threadExecutor = threadExecutorMap.get(threadId); return threadExecutor == null ? null : threadExecutor.getValue(); } @@ -125,7 +125,7 @@ public abstract class ThreadUtils { * search for the corresponding thread by the thread id */ public static Thread findThread(long threadId) { - var threadExecutor = threadExecutorMap.getPrimitive(threadId); + var threadExecutor = threadExecutorMap.get(threadId); if (threadExecutor != null) { return threadExecutor.getKey(); }