From d75a1f1400e634d1119b89657cd888bb642f11f8 Mon Sep 17 00:00:00 2001 From: Zac Sweers Date: Sat, 1 Oct 2016 04:15:48 -0500 Subject: [PATCH 1/2] Upcast ConcurrentHashMap to Map to avoid compatibility issue Resovles #4653 See http://stackoverflow.com/a/32955708/61158 --- .../internal/schedulers/SchedulerPoolFactory.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/reactivex/internal/schedulers/SchedulerPoolFactory.java b/src/main/java/io/reactivex/internal/schedulers/SchedulerPoolFactory.java index 6dfc84ea96..64be5fe2d2 100644 --- a/src/main/java/io/reactivex/internal/schedulers/SchedulerPoolFactory.java +++ b/src/main/java/io/reactivex/internal/schedulers/SchedulerPoolFactory.java @@ -16,13 +16,15 @@ package io.reactivex.internal.schedulers; -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.atomic.AtomicReference; - import io.reactivex.internal.util.SuppressAnimalSniffer; import io.reactivex.plugins.RxJavaPlugins; +import java.util.ArrayList; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.*; +import java.util.concurrent.atomic.AtomicReference; + /** * Manages the creating of ScheduledExecutorServices and sets up purging. */ @@ -46,7 +48,9 @@ public enum SchedulerPoolFactory { static final AtomicReference PURGE_THREAD = new AtomicReference(); - static final ConcurrentHashMap POOLS = + // Upcast to the Map interface here to avoid 8.x compatibility issues. + // See http://stackoverflow.com/a/32955708/61158 + static final Map POOLS = new ConcurrentHashMap(); /** From a6a6fd62cedfa6d532d36738379545e7d00d721c Mon Sep 17 00:00:00 2001 From: Zac Sweers Date: Sat, 1 Oct 2016 04:22:21 -0500 Subject: [PATCH 2/2] Fix imports, remove now-unnecessary animalsniffer suppression --- .../internal/schedulers/SchedulerPoolFactory.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main/java/io/reactivex/internal/schedulers/SchedulerPoolFactory.java b/src/main/java/io/reactivex/internal/schedulers/SchedulerPoolFactory.java index 64be5fe2d2..5124b34a6f 100644 --- a/src/main/java/io/reactivex/internal/schedulers/SchedulerPoolFactory.java +++ b/src/main/java/io/reactivex/internal/schedulers/SchedulerPoolFactory.java @@ -16,15 +16,12 @@ package io.reactivex.internal.schedulers; -import io.reactivex.internal.util.SuppressAnimalSniffer; -import io.reactivex.plugins.RxJavaPlugins; - -import java.util.ArrayList; -import java.util.Map; -import java.util.Properties; +import java.util.*; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicReference; +import io.reactivex.plugins.RxJavaPlugins; + /** * Manages the creating of ScheduledExecutorServices and sets up purging. */ @@ -67,10 +64,9 @@ public static void start() { next.scheduleAtFixedRate(new Runnable() { @Override - @SuppressAnimalSniffer public void run() { try { - for (ScheduledThreadPoolExecutor e : new ArrayList(POOLS.keySet())) { // CHM.keySet returns KeySetView in Java 8+; false positive here + for (ScheduledThreadPoolExecutor e : new ArrayList(POOLS.keySet())) { if (e.isShutdown()) { POOLS.remove(e); } else {