Skip to content

Commit

Permalink
Make StringConverter threadsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
steffenaxer committed Mar 11, 2024
1 parent fb55a1b commit 03487d5
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.matsim.utils.objectattributes.AttributeConverter;

Expand All @@ -29,7 +30,7 @@
* @author mrieser
*/
public class StringConverter implements AttributeConverter<String> {
private final Map<String, String> stringCache = new HashMap<String, String>(1000);
private final Map<String, String> stringCache = new ConcurrentHashMap<>(1000);
@Override
public String convert(String value) {
String s = this.stringCache.get(value);
Expand All @@ -44,4 +45,4 @@ public String convert(String value) {
public String convertToString(Object o) {
return (String) o;
}
}
}

0 comments on commit 03487d5

Please sign in to comment.