Skip to content

Commit

Permalink
Upcast ConcurrentHashMap to Map to avoid compatibility issue (#4654)
Browse files Browse the repository at this point in the history
* Upcast ConcurrentHashMap to Map to avoid compatibility issue

Resovles #4653

See http://stackoverflow.com/a/32955708/61158

* Fix imports, remove now-unnecessary animalsniffer suppression
  • Loading branch information
ZacSweers authored and akarnokd committed Oct 1, 2016
1 parent 5ad1c04 commit 56123c9
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicReference;

import io.reactivex.internal.util.SuppressAnimalSniffer;
import io.reactivex.plugins.RxJavaPlugins;

/**
Expand All @@ -46,7 +45,9 @@ public enum SchedulerPoolFactory {
static final AtomicReference<ScheduledExecutorService> PURGE_THREAD =
new AtomicReference<ScheduledExecutorService>();

static final ConcurrentHashMap<ScheduledThreadPoolExecutor, Object> POOLS =
// Upcast to the Map interface here to avoid 8.x compatibility issues.
// See http://stackoverflow.com/a/32955708/61158
static final Map<ScheduledThreadPoolExecutor, Object> POOLS =
new ConcurrentHashMap<ScheduledThreadPoolExecutor, Object>();

/**
Expand All @@ -63,10 +64,9 @@ public static void start() {

next.scheduleAtFixedRate(new Runnable() {
@Override
@SuppressAnimalSniffer
public void run() {
try {
for (ScheduledThreadPoolExecutor e : new ArrayList<ScheduledThreadPoolExecutor>(POOLS.keySet())) { // CHM.keySet returns KeySetView in Java 8+; false positive here
for (ScheduledThreadPoolExecutor e : new ArrayList<ScheduledThreadPoolExecutor>(POOLS.keySet())) {
if (e.isShutdown()) {
POOLS.remove(e);
} else {
Expand Down

0 comments on commit 56123c9

Please sign in to comment.