From 03487d53036285840019d00ee472196fbac0692a Mon Sep 17 00:00:00 2001 From: steffenaxer <26229392+steffenaxer@users.noreply.github.com> Date: Mon, 11 Mar 2024 22:43:39 +0100 Subject: [PATCH] Make StringConverter threadsafe --- .../attributeconverters/StringConverter.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/matsim/src/main/java/org/matsim/utils/objectattributes/attributeconverters/StringConverter.java b/matsim/src/main/java/org/matsim/utils/objectattributes/attributeconverters/StringConverter.java index 07ede6e8bd5..3a600e82bc1 100644 --- a/matsim/src/main/java/org/matsim/utils/objectattributes/attributeconverters/StringConverter.java +++ b/matsim/src/main/java/org/matsim/utils/objectattributes/attributeconverters/StringConverter.java @@ -21,6 +21,7 @@ import java.util.HashMap; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import org.matsim.utils.objectattributes.AttributeConverter; @@ -29,7 +30,7 @@ * @author mrieser */ public class StringConverter implements AttributeConverter { - private final Map stringCache = new HashMap(1000); + private final Map stringCache = new ConcurrentHashMap<>(1000); @Override public String convert(String value) { String s = this.stringCache.get(value); @@ -44,4 +45,4 @@ public String convert(String value) { public String convertToString(Object o) { return (String) o; } -} \ No newline at end of file +}