Ver Fonte

fix concurrent token value generation

Jan Wittler há 4 anos atrás
pai
commit
b66813ff41
1 ficheiros alterados com 3 adições e 1 exclusões
  1. 3 1
      core/src/main/java/de/jplag/GreedyStringTiling.java

+ 3 - 1
core/src/main/java/de/jplag/GreedyStringTiling.java

@@ -216,7 +216,9 @@ public class GreedyStringTiling {
             int[] tokenValueList = new int[tokens.size()];
             for (int i = 0; i < tokens.size(); i++) {
                 TokenType type = tokens.get(i).getType();
-                tokenTypeValues.putIfAbsent(type, tokenTypeValues.size());
+                synchronized (tokenTypeValues) {
+                    tokenTypeValues.putIfAbsent(type, tokenTypeValues.size());
+                }
                 tokenValueList[i] = tokenTypeValues.get(type);
             }
             return tokenValueList;