From 7242550214f002f15b39b0556a5e1c7e05a29aa4 Mon Sep 17 00:00:00 2001 From: "Peter (Stig) Edwards" Date: Thu, 7 Jul 2016 16:52:07 +0100 Subject: [PATCH] Use thread safe ConcurrentHashMap. (#3) For https://github.com/OpenTSDB/opentsdb/issues/823 Concurrent use of a HashSet can trigger race conditions and an infinite loop(s), use the thread-safe ConcurrentHashMap to avoid this. Making the change just for the thread stack seen looping. Signed-off-by: Chris Larsen --- src/core/SaltScanner.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core/SaltScanner.java b/src/core/SaltScanner.java index 9498284e00..d4b6fa6ded 100644 --- a/src/core/SaltScanner.java +++ b/src/core/SaltScanner.java @@ -15,7 +15,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -306,8 +305,8 @@ final class ScannerCB implements Callback kvs = new ArrayList(); private final ByteMap> annotations = new ByteMap>(); - private final Set skips = new HashSet(); - private final Set keepers = new HashSet(); + private final Set skips = Collections.newSetFromMap(new ConcurrentHashMap()); + private final Set keepers = Collections.newSetFromMap(new ConcurrentHashMap()); private long scanner_start = -1; /** nanosecond timestamps */