From d8735d25aae8c51255459099799d626ca31eeb39 Mon Sep 17 00:00:00 2001 From: Jan Srnicek Date: Wed, 31 Aug 2016 08:36:24 +0200 Subject: HONEYCOMB-144 - Make dump cache manager thread-save Modified to be thread save and generic to be usable in all plugins Change-Id: I26c90e8c8aa13c07fa389d86a9784e92e9532bcd Signed-off-by: Jan Srnicek --- .../java/io/fd/honeycomb/translate/ModificationCache.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'infra/translate-api') diff --git a/infra/translate-api/src/main/java/io/fd/honeycomb/translate/ModificationCache.java b/infra/translate-api/src/main/java/io/fd/honeycomb/translate/ModificationCache.java index dcf97439b..2419ffebe 100644 --- a/infra/translate-api/src/main/java/io/fd/honeycomb/translate/ModificationCache.java +++ b/infra/translate-api/src/main/java/io/fd/honeycomb/translate/ModificationCache.java @@ -16,18 +16,21 @@ package io.fd.honeycomb.translate; -import com.google.common.collect.Maps; -import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import javax.annotation.concurrent.ThreadSafe; /** - * Simple context class that provides transient storage during one or more read/write operations + * Simple context class that provides transient storage during one or more read/write operations. + * Internally Thread-save. */ +@ThreadSafe public class ModificationCache implements AutoCloseable { - protected final HashMap map; + protected final Map map; public ModificationCache() { - map = Maps.newHashMap(); + map = new ConcurrentHashMap<>(); } public Object get(final Object o) { -- cgit 1.2.3-korg