fix : TDI-42776 (#2692)

* fix : TDI-42776

Numeric sequence is now thread safe
This commit is contained in:
Richard Lecomte
2019-08-30 10:50:32 +02:00
committed by GitHub
parent ea091c2cda
commit 2aae24829a

View File

@@ -6,10 +6,11 @@
package routines;
import java.math.BigDecimal;
import java.util.concurrent.ConcurrentHashMap;
public class Numeric {
private static final java.util.Map<String, Integer> seq_Hash = new java.util.HashMap<String, Integer>();
private static final java.util.Map<String, Integer> seq_Hash = new ConcurrentHashMap<>();
/**
* return an incremented numeric id
@@ -30,13 +31,8 @@ public class Numeric {
*
*/
public static Integer sequence(String seqName, int startValue, int step) {
if (seq_Hash.containsKey(seqName)) {
seq_Hash.put(seqName, seq_Hash.get(seqName) + step);
return seq_Hash.get(seqName);
} else {
seq_Hash.put(seqName, startValue);
return startValue;
}
return seq_Hash.compute(seqName,
(String k, Integer v) -> v == null ? startValue : v + step);
}
/**
@@ -68,9 +64,7 @@ public class Numeric {
*/
public static void removeSequence(String seqName) {
if (seq_Hash.containsKey(seqName)) {
seq_Hash.remove(seqName);
}
seq_Hash.remove(seqName);
}
/**