commit | 00fd0f34887581bc4fdf8e098920cca55120520c | [log] [tgz] |
---|---|---|
author | Sorin Basca <sorinbasca@google.com> | Fri Nov 12 18:02:11 2021 +0000 |
committer | Sorin Basca <sorinbasca@google.com> | Fri Nov 12 18:12:36 2021 +0000 |
tree | b1908fd72c75e82a7798bea2b0d2198780d20288 | |
parent | cba1cc86ab7e17422b617754ed2235cfe0df2be1 [diff] |
Reverting checks after toArray() calls This is needed due to revert in I7463c5c2638af53caa2e0db8723167884ab34e4a Test: m Bug: 202956589 Bug: 204397945 Bug: 205812471 Change-Id: I038247bd7e5077981335f441ab38875335a1149c
diff --git a/ojluni/src/main/java/java/util/concurrent/CopyOnWriteArrayList.java b/ojluni/src/main/java/java/util/concurrent/CopyOnWriteArrayList.java index f1a0bed..fb464e9 100644 --- a/ojluni/src/main/java/java/util/concurrent/CopyOnWriteArrayList.java +++ b/ojluni/src/main/java/java/util/concurrent/CopyOnWriteArrayList.java
@@ -141,7 +141,10 @@ es = ((CopyOnWriteArrayList<?>)c).getArray(); else { es = c.toArray(); - if (c.getClass() != java.util.ArrayList.class) + // Android-changed: Defend against c.toArray (incorrectly) not returning Object[] + // (see b/204397945) + // if (c.getClass() != java.util.ArrayList.class) + if (es.getClass() != Object[].class) es = Arrays.copyOf(es, es.length, Object[].class); } setArray(es);
diff --git a/ojluni/src/main/java/java/util/concurrent/PriorityBlockingQueue.java b/ojluni/src/main/java/java/util/concurrent/PriorityBlockingQueue.java index ee1c1b1..c068dee 100644 --- a/ojluni/src/main/java/java/util/concurrent/PriorityBlockingQueue.java +++ b/ojluni/src/main/java/java/util/concurrent/PriorityBlockingQueue.java
@@ -263,7 +263,10 @@ } Object[] es = c.toArray(); int n = es.length; - if (c.getClass() != java.util.ArrayList.class) + // Android-changed: Defend against c.toArray (incorrectly) not returning Object[] + // (see b/204397945) + // if (c.getClass() != java.util.ArrayList.class) + if (es.getClass() != Object[].class) es = Arrays.copyOf(es, n, Object[].class); if (screen && (n == 1 || this.comparator != null)) { for (Object e : es)