different tags could be written to the same file

There was a missing synchronization in the code that maps
Strings to Integers.
This commit is contained in:
2018-07-28 08:37:30 +02:00
parent 3d71befbad
commit bb8dbad393
3 changed files with 61 additions and 2 deletions

View File

@@ -121,8 +121,12 @@ public class UniqueStringIntegerPairs {
public Integer computeIfAbsent(final String first, final Function<String, Integer> mappingFunction) {
if (!stringToInt.containsKey(first)) {
final Integer second = mappingFunction.apply(first);
put(first, second);
synchronized (stringToInt) {
if (!stringToInt.containsKey(first)) {
final Integer second = mappingFunction.apply(first);
put(first, second);
}
}
}
return stringToInt.get(first);