* ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
private volatile String msoConfigPath = null;
private final ConcurrentHashMap<String, Map<String, String>> propFileCache =
- new ConcurrentHashMap<String, Map<String, String>>();
+ new ConcurrentHashMap<>();
private final Object CACHELOCK = new Object();
private FileWatcherThread fileWatcherThread = null;
// The key is the file name
- private Map<String, TimerTask> timerTaskMap = new HashMap<String, TimerTask>();
+ private Map<String, TimerTask> timerTaskMap = new HashMap<>();
+ /**
+ * Private Constructor.
+ */
+ private PropertyConfiguration() {
+ startUp();
+ }
+
/**
* Singleton holder pattern eliminates locking when accessing the instance
* and still provides for lazy initialization.
return PropertyConfigurationInstanceHolder.instance;
}
- /**
- * Returns the list of supported files.
- */
- public static List<String> supportedFiles() {
- return new ArrayList<String>(SUPPORTED_FILES);
+ static void resetPropertyConfigurationSingletonInstance(){
+ PropertyConfigurationInstanceHolder.instance = new PropertyConfiguration();
}
/**
- * Private Constructor.
+ * Returns the list of supported files.
*/
- private PropertyConfiguration() {
- startUp();
+ public static List<String> supportedFiles() {
+ return new ArrayList<>(SUPPORTED_FILES);
}
/**
fileWatcherThread.join(waitInSeconds * 1000);
} catch (InterruptedException e) {
LOGGER.debug("FileWatcherThread " + System.identityHashCode(fileWatcherThread)
- + " shutdown did not occur within " + waitInSeconds + " seconds");
+ + " shutdown did not occur within " + waitInSeconds + " seconds",e);
}
LOGGER.debug("Finished shutting down FileWatcherThread " + System.identityHashCode(fileWatcherThread));
* Reads properties from the specified file, updates the property file cache, and
* returns the properties in a map.
* @param file the file to read
- * @param reload true if this is a reload event
* @return a map of properties
*/
private Map<String, String> readProperties(File file) throws IOException {
String fileName = file.getName();
LOGGER.debug("Reading " + fileName);
- Map<String, String> properties = new HashMap<String, String>();
+ Map<String, String> properties = new HashMap<>();
Properties newProperties = new Properties();
- FileReader reader = null;
- try {
- reader = new FileReader(file);
+ try (FileReader reader = new FileReader(file)) {
newProperties.load(reader);
- } finally {
- if (reader != null) {
- try {
- reader.close();
- LOGGER.debug("Closed " + fileName);
- } catch (Exception e) {
- // Ignore
- }
- }
+ }
+ catch (Exception e) {
+ LOGGER.debug("Exception :",e);
}
for (Entry<Object, Object> entry : newProperties.entrySet()) {
interrupt();
}
+ @Override
public void run() {
LOGGER.info(MessageEnum.BPMN_GENERAL_INFO, "BPMN",
"FileWatcherThread started");
}
}
} catch (InterruptedException e) {
+ LOGGER.debug("InterruptedException :",e);
break;
} catch (ClosedWatchServiceException e) {
LOGGER.info(
MessageEnum.BPMN_GENERAL_INFO,
"BPMN",
"FileWatcherThread shut down because the watch service was closed");
+ LOGGER.debug("ClosedWatchServiceException :",e);
break;
} catch (Exception e) {
LOGGER.error(
watchService.close();
} catch (IOException e) {
LOGGER.debug("FileWatcherThread caught " + e.getClass().getSimpleName()
- + " while closing the watch service");
+ + " while closing the watch service",e);
}
LOGGER.info(MessageEnum.BPMN_GENERAL_INFO, "BPMN",