tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acob...@apache.org
Subject [incubator-tamaya] 01/01: LHF: remove unnecessary volatile keywords
Date Tue, 30 Apr 2019 17:08:50 GMT
This is an automated email from the ASF dual-hosted git repository.

acoburn pushed a commit to branch volatile_cleanup
in repository https://gitbox.apache.org/repos/asf/incubator-tamaya.git

commit 9c5efc3a98ac9df832037f5dd523034d959a86f8
Author: Aaron Coburn <acoburn@apache.org>
AuthorDate: Tue Apr 30 13:06:15 2019 -0400

    LHF: remove unnecessary volatile keywords
    
    Marking these private fields as volatile was unnecessary as they
    are treated, effectively, as final. This commit marks these fields
    as final and, where appropriate, adjusts the field formatting to
    align with checkstyle rules.
---
 .../src/main/java/org/apache/tamaya/spi/ServiceContextManager.java  | 6 +++---
 .../spisupport/propertysource/PropertiesResourcePropertySource.java | 2 +-
 .../tamaya/spisupport/propertysource/SystemPropertySource.java      | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/code/api/src/main/java/org/apache/tamaya/spi/ServiceContextManager.java b/code/api/src/main/java/org/apache/tamaya/spi/ServiceContextManager.java
index 4a5de3a..2acbfca 100644
--- a/code/api/src/main/java/org/apache/tamaya/spi/ServiceContextManager.java
+++ b/code/api/src/main/java/org/apache/tamaya/spi/ServiceContextManager.java
@@ -41,7 +41,7 @@ public final class ServiceContextManager {
     /**
      * The ServiceProvider used.
      */
-    private static volatile Map<ClassLoader, ServiceContext> serviceContexts = new
ConcurrentHashMap<>();
+    private static final Map<ClassLoader, ServiceContext> SERVICE_CONTEXTS = new ConcurrentHashMap<>();
 
     /**
      * Private singletons constructor.
@@ -104,7 +104,7 @@ public final class ServiceContextManager {
 
         ServiceContext previousContext;
         synchronized (ServiceContextManager.class) {
-            previousContext = ServiceContextManager.serviceContexts
+            previousContext = ServiceContextManager.SERVICE_CONTEXTS
                     .put(cl, serviceContext);
         }
         if(previousContext!=null) {
@@ -127,7 +127,7 @@ public final class ServiceContextManager {
      */
     public static ServiceContext getServiceContext(ClassLoader classLoader) {
         Objects.requireNonNull(classLoader, "Classloader required.");
-        return serviceContexts.computeIfAbsent(classLoader, ServiceContextManager::loadDefaultServiceProvider);
+        return SERVICE_CONTEXTS.computeIfAbsent(classLoader, ServiceContextManager::loadDefaultServiceProvider);
     }
 
     /**
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/PropertiesResourcePropertySource.java
b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/PropertiesResourcePropertySource.java
index 3ddc74f..f5901ad 100644
--- a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/PropertiesResourcePropertySource.java
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/PropertiesResourcePropertySource.java
@@ -39,7 +39,7 @@ public class PropertiesResourcePropertySource extends BasePropertySource
{
     /** The logger used. */
     private static final Logger LOGGER = Logger.getLogger(PropertiesResourcePropertySource.class.getName());
 
-    private volatile PropertySourceChangeSupport cachedProperties = new PropertySourceChangeSupport(
+    private final PropertySourceChangeSupport cachedProperties = new PropertySourceChangeSupport(
             ChangeSupport.SUPPORTED, this);
 
     /**
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/SystemPropertySource.java
b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/SystemPropertySource.java
index 72c8af9..699d906 100644
--- a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/SystemPropertySource.java
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/SystemPropertySource.java
@@ -37,9 +37,9 @@ public class SystemPropertySource extends BasePropertySource {
      */
     public static final int DEFAULT_ORDINAL = 1000;
 
-    private AtomicInteger savedHashcode = new AtomicInteger();
+    private final AtomicInteger savedHashcode = new AtomicInteger();
 
-    private volatile PropertySourceChangeSupport cachedProperties = new PropertySourceChangeSupport(
+    private final PropertySourceChangeSupport cachedProperties = new PropertySourceChangeSupport(
             ChangeSupport.SUPPORTED, this);
 
     /**


Mime
View raw message