deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject deltaspike git commit: DELTASPIKE-840 getConfigFilters now returns an immutable List
Date Fri, 27 Feb 2015 07:11:58 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 016cdddbd -> f569c957e


DELTASPIKE-840 getConfigFilters now returns an immutable List

I also improved the concurrency handling internally


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/f569c957
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/f569c957
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/f569c957

Branch: refs/heads/master
Commit: f569c957e5ad1357c22080bfb4c979460cd4d4ef
Parents: 016cddd
Author: Mark Struberg <struberg@apache.org>
Authored: Fri Feb 27 08:10:40 2015 +0100
Committer: Mark Struberg <struberg@apache.org>
Committed: Fri Feb 27 08:10:40 2015 +0100

----------------------------------------------------------------------
 .../deltaspike/core/api/config/ConfigResolver.java | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/f569c957/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java
b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java
index b798d46..69de6fb 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java
@@ -26,6 +26,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -121,7 +122,7 @@ public final class ConfigResolver
      */
     public static void addConfigFilter(ConfigFilter configFilter)
     {
-        List<ConfigFilter> currentConfigFilters = getConfigFilters();
+        List<ConfigFilter> currentConfigFilters = getInternalConfigFilters();
         currentConfigFilters.add(configFilter);
     }
 
@@ -130,11 +131,19 @@ public final class ConfigResolver
      */
     public static List<ConfigFilter> getConfigFilters()
     {
+        return Collections.unmodifiableList(getInternalConfigFilters());
+    }
+
+    /**
+     * @return the {@link ConfigFilter}s for the current application.
+     */
+    private static List<ConfigFilter> getInternalConfigFilters()
+    {
         ClassLoader cl = ClassUtils.getClassLoader(null);
         List<ConfigFilter> currentConfigFilters = configFilters.get(cl);
         if (currentConfigFilters == null)
         {
-            currentConfigFilters = new ArrayList<ConfigFilter>();
+            currentConfigFilters = new CopyOnWriteArrayList<ConfigFilter>();
             configFilters.put(cl, currentConfigFilters);
         }
 
@@ -475,7 +484,7 @@ public final class ConfigResolver
 
     private static String filterConfigValue(String key, String value)
     {
-        List<ConfigFilter> currentConfigFilters = getConfigFilters();
+        List<ConfigFilter> currentConfigFilters = getInternalConfigFilters();
 
         String filteredValue = value;
 
@@ -488,7 +497,7 @@ public final class ConfigResolver
 
     private static String filterConfigValueForLog(String key, String value)
     {
-        List<ConfigFilter> currentConfigFilters = getConfigFilters();
+        List<ConfigFilter> currentConfigFilters = getInternalConfigFilters();
 
         String logValue = value;
 


Mime
View raw message