From 38f9955391b1775b2c003baf5c2b7d0fb1505242 Mon Sep 17 00:00:00 2001 From: hankhill19580 <hankhill19580@gmail.com> Date: Wed, 28 Oct 2020 04:33:47 +0000 Subject: [PATCH] fix android keySet bug that I discovered this morning --- core/java/src/net/i2p/util/ObjectCounter.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/java/src/net/i2p/util/ObjectCounter.java b/core/java/src/net/i2p/util/ObjectCounter.java index 9e04cd20ea..67f979cf3b 100644 --- a/core/java/src/net/i2p/util/ObjectCounter.java +++ b/core/java/src/net/i2p/util/ObjectCounter.java @@ -2,6 +2,7 @@ package net.i2p.util; import java.io.Serializable; import java.util.Set; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; @@ -45,8 +46,15 @@ public class ObjectCounter<K> implements Serializable { /** * @return set of objects with counts > 0 + * + * note that on Android ConcurrentMap.keySet() returns a Set instead of a + * keySetView. The workaround is to cast it to a map before returning the + * keySet on Android. */ public Set<K> objects() { + if (System.getProperty("java.vendor").toUpperCase().contains("ANDROID")){ + return ((Map< K, ?>)this.map).keySet(); + } return this.map.keySet(); } -- GitLab