diff options
author | Henrik Andersson <henrik.b.andersson@est.tech> | 2019-06-04 06:57:26 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-06-04 06:57:26 +0000 |
commit | c82fc8635874821324b15f9516d5ea04cf4a8704 (patch) | |
tree | 7c141fad566ebd11997c9b4db6dd16df27a4975b | |
parent | 5f4db4fa6b9468c3595fecb73c29d374ca176297 (diff) | |
parent | 20b9271b8c93e9911ba49851d0bf6099eef1d97d (diff) |
Merge "DFC, Purging the cache of published files occasionally fails"
-rw-r--r-- | datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/service/PublishedFileCache.java | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/service/PublishedFileCache.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/service/PublishedFileCache.java index ff267815..475e0224 100644 --- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/service/PublishedFileCache.java +++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/service/PublishedFileCache.java @@ -28,7 +28,7 @@ import java.util.Map; * the key was last used. */ public class PublishedFileCache { - private final Map<Path, Instant> publishedFiles = Collections.synchronizedMap(new HashMap<Path, Instant>()); + private final Map<Path, Instant> publishedFiles = new HashMap<Path, Instant>(); /** * Adds a file to the cache. @@ -36,7 +36,7 @@ public class PublishedFileCache { * @param path the name of the file to add. * @return <code>null</code> if the file is not already in the cache. */ - public Instant put(Path path) { + public synchronized Instant put(Path path) { return publishedFiles.put(path, Instant.now()); } @@ -45,7 +45,7 @@ public class PublishedFileCache { * * @param localFileName name of the file to remove. */ - public void remove(Path localFileName) { + public synchronized void remove(Path localFileName) { publishedFiles.remove(localFileName); } @@ -54,7 +54,7 @@ public class PublishedFileCache { * * @param now the instant will determine which files that will be purged. */ - public void purge(Instant now) { + public synchronized void purge(Instant now) { for (Iterator<Map.Entry<Path, Instant>> it = publishedFiles.entrySet().iterator(); it.hasNext();) { Map.Entry<Path, Instant> pair = it.next(); if (isCachedPublishedFileOutdated(now, pair.getValue())) { @@ -63,7 +63,7 @@ public class PublishedFileCache { } } - public int size() { + public synchronized int size() { return publishedFiles.size(); } |