This is an automated email from the ASF dual-hosted git repository.
liujun pushed a commit to branch 3.2
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.2 by this push:
new ee3855e2f4 Fix LRUCache.putIfAbsent concurrent issue (#14615)
ee3855e2f4 is described below
commit ee3855e2f42bfbc84acb3c9ef7c74202f9226273
Author: Albumen Kevin <[email protected]>
AuthorDate: Mon Sep 2 19:11:51 2024 +0800
Fix LRUCache.putIfAbsent concurrent issue (#14615)
---
.../src/main/java/org/apache/dubbo/common/utils/LRUCache.java | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git
a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/LRUCache.java
b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/LRUCache.java
index 76d6c19cb7..28440ba854 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/LRUCache.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/LRUCache.java
@@ -110,6 +110,16 @@ public class LRUCache<K, V> extends LinkedHashMap<K, V> {
}
}
+ @Override
+ public V putIfAbsent(K key, V value) {
+ lock.lock();
+ try {
+ return super.putIfAbsent(key, value);
+ } finally {
+ lock.unlock();
+ }
+ }
+
public void lock() {
lock.lock();
}