From 03689143896f69617ab9a920428664d926b62d46 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 3a929cd2af..ce4e433c1a 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 */