src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java
changeset 49792 cfdce76e0449
parent 49565 b5705ade8c8d
child 50229 6b29ef846c5c
equal deleted inserted replaced
49791:a0ac3c9b76dc 49792:cfdce76e0449
    49 import java.util.SortedSet;
    49 import java.util.SortedSet;
    50 import java.util.Spliterator;
    50 import java.util.Spliterator;
    51 import java.util.concurrent.locks.Condition;
    51 import java.util.concurrent.locks.Condition;
    52 import java.util.concurrent.locks.ReentrantLock;
    52 import java.util.concurrent.locks.ReentrantLock;
    53 import java.util.function.Consumer;
    53 import java.util.function.Consumer;
       
    54 import jdk.internal.misc.SharedSecrets;
    54 
    55 
    55 /**
    56 /**
    56  * An unbounded {@linkplain BlockingQueue blocking queue} that uses
    57  * An unbounded {@linkplain BlockingQueue blocking queue} that uses
    57  * the same ordering rules as class {@link PriorityQueue} and supplies
    58  * the same ordering rules as class {@link PriorityQueue} and supplies
    58  * blocking retrieval operations.  While this queue is logically
    59  * blocking retrieval operations.  While this queue is logically
   919      */
   920      */
   920     private void readObject(java.io.ObjectInputStream s)
   921     private void readObject(java.io.ObjectInputStream s)
   921         throws java.io.IOException, ClassNotFoundException {
   922         throws java.io.IOException, ClassNotFoundException {
   922         try {
   923         try {
   923             s.defaultReadObject();
   924             s.defaultReadObject();
   924             this.queue = new Object[q.size()];
   925             int sz = q.size();
       
   926             SharedSecrets.getJavaObjectInputStreamAccess().checkArray(s, Object[].class, sz);
       
   927             this.queue = new Object[sz];
   925             comparator = q.comparator();
   928             comparator = q.comparator();
   926             addAll(q);
   929             addAll(q);
   927         } finally {
   930         } finally {
   928             q = null;
   931             q = null;
   929         }
   932         }