Skip to content

Commit

Permalink
Use thread safe ConcurrentHashMap. (tsuna#3)
Browse files Browse the repository at this point in the history
For OpenTSDB#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 <[email protected]>
  • Loading branch information
thatsafunnyname authored and manolama committed Jul 13, 2016
1 parent 93906ca commit 6582775
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/core/SaltScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -306,8 +305,8 @@ final class ScannerCB implements Callback<Object,
private final List<KeyValue> kvs = new ArrayList<KeyValue>();
private final ByteMap<List<Annotation>> annotations =
new ByteMap<List<Annotation>>();
private final Set<String> skips = new HashSet<String>();
private final Set<String> keepers = new HashSet<String>();
private final Set<String> skips = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
private final Set<String> keepers = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());

private long scanner_start = -1;
/** nanosecond timestamps */
Expand Down

0 comments on commit 6582775

Please sign in to comment.