aboutsummaryrefslogtreecommitdiffstats
path: root/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/PropertyUtil.java
diff options
context:
space:
mode:
Diffstat (limited to 'common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/PropertyUtil.java')
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/PropertyUtil.java22
1 files changed, 11 insertions, 11 deletions
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/PropertyUtil.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/PropertyUtil.java
index 38759bc2..ef6c2e95 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/PropertyUtil.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/PropertyUtil.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-Logging
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,13 +32,17 @@ import java.util.Properties;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
/**
* This class provides utilities to read properties from a properties file, and optionally get
* notifications of future changes.
*/
-public class PropertyUtil {
+public final class PropertyUtil {
+
+ @NoArgsConstructor(access = AccessLevel.PRIVATE)
protected static class LazyHolder {
/**
* Timer thread. Will not be allocated by the JVM until it is first referenced.
@@ -60,17 +64,13 @@ public class PropertyUtil {
*/
public static Properties getProperties(File file) throws IOException {
// create an InputStream (may throw a FileNotFoundException)
- FileInputStream fis = new FileInputStream(file);
- try {
+ try (var fis = new FileInputStream(file)) {
// create the properties instance
- Properties rval = new Properties();
+ var rval = new Properties();
// load properties (may throw an IOException)
rval.load(fis);
return rval;
- } finally {
- // close input stream
- fis.close();
}
}
@@ -202,7 +202,7 @@ public class PropertyUtil {
lastModified = timestamp;
// Save old set, and initial set of changed properties.
- Properties oldProperties = properties;
+ var oldProperties = properties;
HashSet<String> changedProperties = new HashSet<>(oldProperties.stringPropertyNames());
// Fetch the list of listeners that we will potentially notify,
@@ -238,7 +238,7 @@ public class PropertyUtil {
for (final Listener notify : listeners) {
// Copy 'properties' and 'changedProperties', so it doesn't
// cause problems if the recipient makes changes.
- final Properties tmpProperties = (Properties) (properties.clone());
+ final var tmpProperties = (Properties) (properties.clone());
final HashSet<String> tmpChangedProperties = new HashSet<>(changedProperties);
// Do the notification in a separate thread, so blocking
@@ -276,7 +276,7 @@ public class PropertyUtil {
// Convert the file to a canonical form in order to avoid the situation
// where different names refer to the same file.
- File tempFile = file.getCanonicalFile();
+ var tempFile = file.getCanonicalFile();
// See if there is an existing registration. The 'synchronized' block
// is needed to handle the case where a new listener is added at about