Skip to content

Commit 56123c9

Browse files
ZacSweersakarnokd
authored andcommitted
Upcast ConcurrentHashMap to Map to avoid compatibility issue (#4654)
* Upcast ConcurrentHashMap to Map to avoid compatibility issue Resovles #4653 See http://stackoverflow.com/a/32955708/61158 * Fix imports, remove now-unnecessary animalsniffer suppression
1 parent 5ad1c04 commit 56123c9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/io/reactivex/internal/schedulers/SchedulerPoolFactory.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.util.concurrent.*;
2121
import java.util.concurrent.atomic.AtomicReference;
2222

23-
import io.reactivex.internal.util.SuppressAnimalSniffer;
2423
import io.reactivex.plugins.RxJavaPlugins;
2524

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

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

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

6465
next.scheduleAtFixedRate(new Runnable() {
6566
@Override
66-
@SuppressAnimalSniffer
6767
public void run() {
6868
try {
69-
for (ScheduledThreadPoolExecutor e : new ArrayList<ScheduledThreadPoolExecutor>(POOLS.keySet())) { // CHM.keySet returns KeySetView in Java 8+; false positive here
69+
for (ScheduledThreadPoolExecutor e : new ArrayList<ScheduledThreadPoolExecutor>(POOLS.keySet())) {
7070
if (e.isShutdown()) {
7171
POOLS.remove(e);
7272
} else {

0 commit comments

Comments
 (0)