You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by rm...@apache.org on 2020/07/29 11:29:25 UTC

[openwebbeans] branch master updated: [OWB-1344] ensure we atomically populate repeatableMethodCache, thanks Vincente Rossello for the report and analyzis

This is an automated email from the ASF dual-hosted git repository.

rmannibucau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwebbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 4325332  [OWB-1344] ensure we atomically populate repeatableMethodCache, thanks Vincente Rossello for the report and analyzis
4325332 is described below

commit 432533265f3ff69dab9d0a79762de7dbe174e8cf
Author: Romain Manni-Bucau <rm...@gmail.com>
AuthorDate: Wed Jul 29 13:29:18 2020 +0200

    [OWB-1344] ensure we atomically populate repeatableMethodCache, thanks Vincente Rossello for the report and analyzis
---
 .../apache/webbeans/annotation/AnnotationManager.java  | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java b/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java
index 24033f4..b5442c4 100644
--- a/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java
+++ b/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java
@@ -62,7 +62,7 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.ConcurrentMap;
 
 /**
  * Manages annotation usage by classes in this application.
@@ -74,8 +74,7 @@ public final class AnnotationManager
     private Map<Class<? extends Annotation>, Boolean> checkedStereotypeAnnotations =
         new ConcurrentHashMap<>();
 
-    private CopyOnWriteArraySet<Class<?>> repeatableMethodCheckedTypes = new CopyOnWriteArraySet<>();
-    private Map<Class<?>, Optional<Method>> repeatableMethodCache = new ConcurrentHashMap<>();
+    private ConcurrentMap<Class<?>, Optional<Method>> repeatableMethodCache = new ConcurrentHashMap<>();
 
     private final BeanManagerImpl beanManagerImpl;
     private final WebBeansContext webBeansContext;
@@ -938,23 +937,12 @@ public final class AnnotationManager
     
     public void clearCaches()
     {
-        repeatableMethodCheckedTypes.clear();
         repeatableMethodCache.clear();
     }
 
     public Optional<Method> getRepeatableMethod(Class<?> type)
     {
-        if (repeatableMethodCheckedTypes.contains(type))
-        {
-            return repeatableMethodCache.get(type);
-        }
-
-        Optional<Method> method = Optional.ofNullable(resolveRepeatableMethod(type));
-        
-        repeatableMethodCheckedTypes.add(type);
-        repeatableMethodCache.put(type, method); // don't put null here!
-        
-        return method;
+        return repeatableMethodCache.computeIfAbsent(type, it -> Optional.ofNullable(resolveRepeatableMethod(it)));
     }
         
     protected Method resolveRepeatableMethod(Class<?> type)