You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by ac...@apache.org on 2019/04/30 17:08:49 UTC
[incubator-tamaya] branch volatile_cleanup created (now 9c5efc3)
This is an automated email from the ASF dual-hosted git repository.
acoburn pushed a change to branch volatile_cleanup
in repository https://gitbox.apache.org/repos/asf/incubator-tamaya.git.
at 9c5efc3 LHF: remove unnecessary volatile keywords
This branch includes the following new commits:
new 9c5efc3 LHF: remove unnecessary volatile keywords
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[incubator-tamaya] 01/01: LHF: remove unnecessary volatile keywords
Posted by ac...@apache.org.
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 <ac...@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);
/**