Fixed further issues from quality gates.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/fefbeca7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/fefbeca7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/fefbeca7 Branch: refs/heads/old_master Commit: fefbeca7f3263e622d6f90dc87faf247c107c42b Parents: 4d6c713 Author: anatole <anat...@apache.org> Authored: Sun Jan 10 02:14:41 2016 +0100 Committer: Oliver B. Fischer <ple...@apache.org> Committed: Fri Sep 30 21:29:37 2016 +0200 ---------------------------------------------------------------------- src/main/java/org/apache/tamaya/events/ChangeType.java | 5 ++++- .../java/org/apache/tamaya/events/ConfigEventManager.java | 2 +- .../org/apache/tamaya/events/ConfigurationChange.java | 4 ++-- .../apache/tamaya/events/ConfigurationChangeBuilder.java | 6 ++++-- .../apache/tamaya/events/ConfigurationContextChange.java | 4 ++-- .../tamaya/events/ConfigurationContextChangeBuilder.java | 2 +- .../org/apache/tamaya/events/FrozenPropertySource.java | 4 ++-- .../org/apache/tamaya/events/PropertySourceChange.java | 6 +++--- .../apache/tamaya/events/PropertySourceChangeBuilder.java | 6 ++++-- .../tamaya/events/folderobserver/FileChangeListener.java | 6 +++--- .../folderobserver/ObservingPropertySourceProvider.java | 4 ++-- .../events/internal/DefaultConfigChangeObserver.java | 6 +++--- .../events/internal/DefaultConfigEventManagerSpi.java | 10 +++++----- .../org/apache/tamaya/events/spi/BaseConfigEvent.java | 6 +++--- .../tamaya/events/ChangeableGlobalPropertySource.java | 2 +- .../events/ChangeableThreadLocalPropertySource.java | 2 +- .../events/internal/DefaultConfigEventManagerSpiTest.java | 2 +- 17 files changed, 42 insertions(+), 35 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/ChangeType.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/tamaya/events/ChangeType.java b/src/main/java/org/apache/tamaya/events/ChangeType.java index 4363579..2059017 100644 --- a/src/main/java/org/apache/tamaya/events/ChangeType.java +++ b/src/main/java/org/apache/tamaya/events/ChangeType.java @@ -19,10 +19,13 @@ package org.apache.tamaya.events; /** - * Created by Anatole on 20.02.2015. + * Enum describing the type of configuration change. */ public enum ChangeType { + /** Configuration hase been added. */ NEW, + /** Configuration hase been removed. */ DELETED, + /** Configuration hase been changed. */ UPDATED, } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/ConfigEventManager.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/tamaya/events/ConfigEventManager.java b/src/main/java/org/apache/tamaya/events/ConfigEventManager.java index f0bd0fa..6b206c8 100644 --- a/src/main/java/org/apache/tamaya/events/ConfigEventManager.java +++ b/src/main/java/org/apache/tamaya/events/ConfigEventManager.java @@ -166,7 +166,7 @@ public final class ConfigEventManager { /** * Sets the current monitoring period and restarts the monitor. You still have to enable the monitor if * it is currently not enabled. - * @param millis + * @param millis the monitoring period in ms. * @see #enableChangeMonitoring(boolean) * @see #isChangeMonitoring() */ http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/ConfigurationChange.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/tamaya/events/ConfigurationChange.java b/src/main/java/org/apache/tamaya/events/ConfigurationChange.java index 0366556..c31cda2 100644 --- a/src/main/java/org/apache/tamaya/events/ConfigurationChange.java +++ b/src/main/java/org/apache/tamaya/events/ConfigurationChange.java @@ -39,13 +39,13 @@ public final class ConfigurationChange implements ConfigEvent<Configuration>, Se private static final long serialVersionUID = 1L; /** The base property provider/configuration. */ - private FrozenConfiguration configuration; + private final FrozenConfiguration configuration; /** The base version, usable for optimistic locking. */ private String version = UUID.randomUUID().toString(); /** The timestamp of the change set in millis from the epoch. */ private long timestamp = System.currentTimeMillis(); /** The recorded changes. */ - private Map<String,PropertyChangeEvent> changes = new HashMap<>(); + private final Map<String,PropertyChangeEvent> changes = new HashMap<>(); /** * Get an empty change set for the given provider. http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/ConfigurationChangeBuilder.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/tamaya/events/ConfigurationChangeBuilder.java b/src/main/java/org/apache/tamaya/events/ConfigurationChangeBuilder.java index 78f60a9..1fd228a 100644 --- a/src/main/java/org/apache/tamaya/events/ConfigurationChangeBuilder.java +++ b/src/main/java/org/apache/tamaya/events/ConfigurationChangeBuilder.java @@ -50,7 +50,7 @@ public final class ConfigurationChangeBuilder { /** * The underlying configuration/provider. */ - Configuration source; + final Configuration source; /** * The version configured, or null, for generating a default. */ @@ -213,7 +213,9 @@ public final class ConfigurationChangeBuilder { * @return the builder for chaining. */ public ConfigurationChangeBuilder putAll(Map<String, String> changes) { - changes.putAll(changes); + for (Map.Entry<String, String> en : changes.entrySet()) { + this.delta.put(en.getKey(), new PropertyChangeEvent(this.source, en.getKey(), null, en.getValue())); + } return this; } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java b/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java index eda5ab1..8c9ceef 100644 --- a/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java +++ b/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java @@ -39,13 +39,13 @@ public final class ConfigurationContextChange implements ConfigEvent<Configurati private static final long serialVersionUID = 1L; /** The base property provider/configuration. */ - private List<PropertySourceChange> changedPropertySources = new ArrayList<>(); + private final List<PropertySourceChange> changedPropertySources = new ArrayList<>(); /** The base version, usable for optimistic locking. */ private String version = UUID.randomUUID().toString(); /** The timestamp of the change set in millis from the epoch. */ private long timestamp = System.currentTimeMillis(); /** The configuration context. */ - private ConfigurationContext configurationContext; + private final ConfigurationContext configurationContext; /** * Get an empty change set for the given provider. http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java b/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java index 2341f92..a48107a 100644 --- a/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java +++ b/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java @@ -52,7 +52,7 @@ public final class ConfigurationContextChangeBuilder { */ Long timestamp; - ConfigurationContext configurationContext; + final ConfigurationContext configurationContext; /** * Constructor. http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java b/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java index 12778be..a8167f2 100644 --- a/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java +++ b/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java @@ -34,7 +34,7 @@ public final class FrozenPropertySource implements PropertySource, Serializable /** * The ordinal. */ - private int ordinal; + private final int ordinal; /** * The properties read. */ @@ -42,7 +42,7 @@ public final class FrozenPropertySource implements PropertySource, Serializable /** * The PropertySource's name. */ - private String name; + private final String name; /** * Constructor. http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/PropertySourceChange.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/tamaya/events/PropertySourceChange.java b/src/main/java/org/apache/tamaya/events/PropertySourceChange.java index a34e949..063612c 100644 --- a/src/main/java/org/apache/tamaya/events/PropertySourceChange.java +++ b/src/main/java/org/apache/tamaya/events/PropertySourceChange.java @@ -39,15 +39,15 @@ public final class PropertySourceChange implements ConfigEvent<PropertySource>, private static final long serialVersionUID = 1L; /** The base property provider/configuration. */ - private FrozenPropertySource propertySource; + private final FrozenPropertySource propertySource; /** The base version, usable for optimistic locking. */ private String version = UUID.randomUUID().toString(); /** The timestamp of the change set in millis from the epoch. */ private long timestamp = System.currentTimeMillis(); /** The recorded changes. */ - private Map<String,PropertyChangeEvent> changes = new HashMap<>(); + private final Map<String,PropertyChangeEvent> changes = new HashMap<>(); /** The overall type of change. */ - private ChangeType changeType; + private final ChangeType changeType; /** * Constructor used by {@link PropertySourceChangeBuilder}. http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java b/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java index 25f3620..009cb11 100644 --- a/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java +++ b/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java @@ -49,7 +49,7 @@ public final class PropertySourceChangeBuilder { /** * The underlying configuration/provider. */ - PropertySource source; + final PropertySource source; /** * The version configured, or null, for generating a default. */ @@ -196,7 +196,9 @@ public final class PropertySourceChangeBuilder { * @return the builder for chaining. */ public PropertySourceChangeBuilder putAll(Map<String, String> changes) { - changes.putAll(changes); + for (Map.Entry<String, String> en : this.source.getProperties().entrySet()) { + this.delta.put(en.getKey(), new PropertyChangeEvent(this.source, en.getKey(), null, en.getValue())); + } return this; } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java b/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java index 3427ce8..283719e 100644 --- a/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java +++ b/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java @@ -45,11 +45,11 @@ class FileChangeListener implements Runnable { private static final Logger LOGGER = Logger.getLogger(FileChangeListener.class.getName()); - private WatchService watchService; + private final WatchService watchService; - private FileChangeObserver observer; + private final FileChangeObserver observer; - private Path directory; + private final Path directory; private volatile boolean running = true; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java b/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java index d8c869f..6082dd0 100644 --- a/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java +++ b/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java @@ -59,7 +59,7 @@ public class ObservingPropertySourceProvider implements PropertySourceProvider, /** * The thread pool used. */ - private ExecutorService executor = Executors.newSingleThreadExecutor(); + private final ExecutorService executor = Executors.newSingleThreadExecutor(); /** * Constructorm using an explicit directory, ignoring all kind of configuration, if set. @@ -103,7 +103,7 @@ public class ObservingPropertySourceProvider implements PropertySourceProvider, protected Collection<PropertySource> getPropertySources(final Path file) { return Arrays.asList(new PropertySource[]{new BasePropertySource() { - private Map<String,String> props = readProperties(file); + private final Map<String,String> props = readProperties(file); @Override public Map<String, String> getProperties() { return props; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java b/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java index dfb3816..5cd3f6c 100644 --- a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java +++ b/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java @@ -36,7 +36,7 @@ public class DefaultConfigChangeObserver { private static final Logger LOG = Logger.getLogger(DefaultConfigChangeObserver.class.getName()); - private Timer timer = new Timer("DefaultConfigChangeObserver", true); + private final Timer timer = new Timer("DefaultConfigChangeObserver", true); private long checkPeriod = 2000L; @@ -63,7 +63,7 @@ public class DefaultConfigChangeObserver { public void checkConfigurationUpdate() { LOG.finest("Checking configuration for changes..."); FrozenConfiguration newConfig = FrozenConfiguration.of(ConfigurationProvider.getConfiguration()); - ConfigurationChange changes = null; + ConfigurationChange changes; if(lastConfig==null){ changes = ConfigurationChangeBuilder.of(newConfig).putAll(newConfig.getProperties()) .build(); @@ -92,7 +92,7 @@ public class DefaultConfigChangeObserver { /** * Sets the new check period, cancels the currently running timer and schedules a new task with the new checkperiod * and a startup delay of 500ms. - * @param checkPeriod + * @param checkPeriod the period in ms, for checking on changes. */ public void setCheckPeriod(long checkPeriod) { LOG.finest("Resetting check period to " + checkPeriod + " ms, reregistering timer."); http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java b/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java index 75f2c91..586df5c 100644 --- a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java +++ b/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java @@ -38,11 +38,11 @@ public class DefaultConfigEventManagerSpi implements ConfigEventManagerSpi { private static final Logger LOG = Logger.getLogger(DefaultConfigEventManagerSpi.class.getName()); - private Map<Class,List<ConfigEventListener>> listeners = new ConcurrentHashMap<>(); + private final Map<Class,List<ConfigEventListener>> listeners = new ConcurrentHashMap<>(); - private ExecutorService publisher = Executors.newCachedThreadPool(); + private final ExecutorService publisher = Executors.newCachedThreadPool(); - private DefaultConfigChangeObserver changeObserver = new DefaultConfigChangeObserver(); + private final DefaultConfigChangeObserver changeObserver = new DefaultConfigChangeObserver(); /** * Constructor. Also loads all registered listeners. @@ -186,8 +186,8 @@ public class DefaultConfigEventManagerSpi implements ConfigEventManagerSpi { */ private static final class PublishConfigChangeTask implements Runnable{ - private ConfigEventListener l; - private ConfigEvent<?> changes; + private final ConfigEventListener l; + private final ConfigEvent<?> changes; public PublishConfigChangeTask(ConfigEventListener l, ConfigEvent<?> changes) { this.l = Objects.requireNonNull(l); http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java b/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java index 15f3dfd..f6856d9 100644 --- a/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java +++ b/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java @@ -28,10 +28,10 @@ import java.util.UUID; * @param <T> the vent type */ public abstract class BaseConfigEvent<T> implements ConfigEvent<T> { - private long timestamp = System.currentTimeMillis(); + protected long timestamp = System.currentTimeMillis(); protected String version = UUID.randomUUID().toString(); - protected T paylod; - private Class<T> type; + protected final T paylod; + private final Class<T> type; public BaseConfigEvent(T paylod, Class<T> type){ this.paylod = Objects.requireNonNull(paylod); http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java b/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java index c93b2ca..0384064 100644 --- a/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java +++ b/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java @@ -29,7 +29,7 @@ import java.util.concurrent.ConcurrentHashMap; */ public class ChangeableGlobalPropertySource extends BasePropertySource{ - private static Map<String,String> STORED_ENTRIES = new ConcurrentHashMap<>(); + private static final Map<String,String> STORED_ENTRIES = new ConcurrentHashMap<>(); @Override public String getName() { http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java b/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java index 759d429..cc6c812 100644 --- a/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java +++ b/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java @@ -30,7 +30,7 @@ import java.util.Map; */ public class ChangeableThreadLocalPropertySource extends BasePropertySource{ - private static ThreadLocal<Map<String,String>> STORED_ENTRIES = new ThreadLocal<Map<String,String>>(){ + private static final ThreadLocal<Map<String,String>> STORED_ENTRIES = new ThreadLocal<Map<String,String>>(){ protected Map<String,String> initialValue(){ return new HashMap<>(); } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/test/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpiTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpiTest.java b/src/test/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpiTest.java index 55b49dc..d54a66e 100644 --- a/src/test/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpiTest.java +++ b/src/test/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpiTest.java @@ -30,7 +30,7 @@ import static org.junit.Assert.assertEquals; */ public class DefaultConfigEventManagerSpiTest { - private DefaultConfigEventManagerSpi spi = new DefaultConfigEventManagerSpi(); + private final DefaultConfigEventManagerSpi spi = new DefaultConfigEventManagerSpi(); private Object testAddListenerValue; @Test