Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upcast ConcurrentHashMap to Map to avoid compatibility issue #4654

Merged
merged 2 commits into from
Oct 1, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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