1 |
|
/* |
2 |
|
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
< |
* http://creativecommons.org/licenses/publicdomain |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
* Other contributors include Andrew Wright, Jeffrey Hayes, |
6 |
|
* Pat Fisher, Mike Judd. |
7 |
|
*/ |
8 |
|
|
9 |
< |
import junit.framework.*; |
10 |
< |
import java.util.*; |
11 |
< |
import java.util.concurrent.*; |
12 |
< |
import java.io.*; |
9 |
> |
import static java.util.concurrent.TimeUnit.MILLISECONDS; |
10 |
> |
|
11 |
> |
import java.util.ArrayList; |
12 |
> |
import java.util.Arrays; |
13 |
> |
import java.util.Collection; |
14 |
> |
import java.util.Comparator; |
15 |
> |
import java.util.Iterator; |
16 |
> |
import java.util.NoSuchElementException; |
17 |
> |
import java.util.Queue; |
18 |
> |
import java.util.concurrent.BlockingQueue; |
19 |
> |
import java.util.concurrent.CountDownLatch; |
20 |
> |
import java.util.concurrent.Executors; |
21 |
> |
import java.util.concurrent.ExecutorService; |
22 |
> |
import java.util.concurrent.PriorityBlockingQueue; |
23 |
> |
import java.util.concurrent.ThreadLocalRandom; |
24 |
> |
|
25 |
> |
import junit.framework.Test; |
26 |
|
|
27 |
|
public class PriorityBlockingQueueTest extends JSR166TestCase { |
28 |
+ |
|
29 |
+ |
public static class Generic extends BlockingQueueTest { |
30 |
+ |
protected BlockingQueue emptyCollection() { |
31 |
+ |
return new PriorityBlockingQueue(); |
32 |
+ |
} |
33 |
+ |
} |
34 |
+ |
|
35 |
+ |
public static class InitialCapacity extends BlockingQueueTest { |
36 |
+ |
protected BlockingQueue emptyCollection() { |
37 |
+ |
ThreadLocalRandom rnd = ThreadLocalRandom.current(); |
38 |
+ |
int initialCapacity = rnd.nextInt(1, SIZE); |
39 |
+ |
return new PriorityBlockingQueue(initialCapacity); |
40 |
+ |
} |
41 |
+ |
} |
42 |
+ |
|
43 |
|
public static void main(String[] args) { |
44 |
< |
junit.textui.TestRunner.run (suite()); |
44 |
> |
main(suite(), args); |
45 |
|
} |
46 |
+ |
|
47 |
|
public static Test suite() { |
48 |
< |
return new TestSuite(PriorityBlockingQueueTest.class); |
48 |
> |
class Implementation implements CollectionImplementation { |
49 |
> |
public Class<?> klazz() { return PriorityBlockingQueue.class; } |
50 |
> |
public Collection emptyCollection() { |
51 |
> |
return new PriorityBlockingQueue(); |
52 |
> |
} |
53 |
> |
public Object makeElement(int i) { return i; } |
54 |
> |
public boolean isConcurrent() { return true; } |
55 |
> |
public boolean permitsNulls() { return false; } |
56 |
> |
} |
57 |
> |
class ComparatorImplementation implements CollectionImplementation { |
58 |
> |
public Class<?> klazz() { return PriorityBlockingQueue.class; } |
59 |
> |
public Collection emptyCollection() { |
60 |
> |
ThreadLocalRandom rnd = ThreadLocalRandom.current(); |
61 |
> |
int initialCapacity = rnd.nextInt(1, 10); |
62 |
> |
return new PriorityBlockingQueue( |
63 |
> |
initialCapacity, new MyReverseComparator()); |
64 |
> |
} |
65 |
> |
public Object makeElement(int i) { return i; } |
66 |
> |
public boolean isConcurrent() { return true; } |
67 |
> |
public boolean permitsNulls() { return false; } |
68 |
> |
} |
69 |
> |
return newTestSuite( |
70 |
> |
PriorityBlockingQueueTest.class, |
71 |
> |
new Generic().testSuite(), |
72 |
> |
new InitialCapacity().testSuite(), |
73 |
> |
CollectionTest.testSuite(new Implementation()), |
74 |
> |
CollectionTest.testSuite(new ComparatorImplementation())); |
75 |
|
} |
76 |
|
|
22 |
– |
private static final int NOCAP = Integer.MAX_VALUE; |
23 |
– |
|
77 |
|
/** Sample Comparator */ |
78 |
< |
static class MyReverseComparator implements Comparator { |
78 |
> |
static class MyReverseComparator implements Comparator, java.io.Serializable { |
79 |
|
public int compare(Object x, Object y) { |
80 |
< |
int i = ((Integer)x).intValue(); |
28 |
< |
int j = ((Integer)y).intValue(); |
29 |
< |
if (i < j) return 1; |
30 |
< |
if (i > j) return -1; |
31 |
< |
return 0; |
80 |
> |
return ((Comparable)y).compareTo(x); |
81 |
|
} |
82 |
|
} |
83 |
|
|
84 |
|
/** |
85 |
< |
* Create a queue of given size containing consecutive |
86 |
< |
* Integers 0 ... n. |
85 |
> |
* Returns a new queue of given size containing consecutive |
86 |
> |
* Integers 0 ... n - 1. |
87 |
|
*/ |
88 |
< |
private PriorityBlockingQueue populatedQueue(int n) { |
89 |
< |
PriorityBlockingQueue q = new PriorityBlockingQueue(n); |
88 |
> |
private static PriorityBlockingQueue<Integer> populatedQueue(int n) { |
89 |
> |
PriorityBlockingQueue<Integer> q = |
90 |
> |
new PriorityBlockingQueue<Integer>(n); |
91 |
|
assertTrue(q.isEmpty()); |
92 |
< |
for (int i = n-1; i >= 0; i-=2) |
93 |
< |
assertTrue(q.offer(new Integer(i))); |
94 |
< |
for (int i = (n & 1); i < n; i+=2) |
95 |
< |
assertTrue(q.offer(new Integer(i))); |
92 |
> |
for (int i = n - 1; i >= 0; i -= 2) |
93 |
> |
assertTrue(q.offer(new Integer(i))); |
94 |
> |
for (int i = (n & 1); i < n; i += 2) |
95 |
> |
assertTrue(q.offer(new Integer(i))); |
96 |
|
assertFalse(q.isEmpty()); |
97 |
< |
assertEquals(NOCAP, q.remainingCapacity()); |
98 |
< |
assertEquals(n, q.size()); |
97 |
> |
assertEquals(Integer.MAX_VALUE, q.remainingCapacity()); |
98 |
> |
assertEquals(n, q.size()); |
99 |
> |
assertEquals((Integer) 0, q.peek()); |
100 |
|
return q; |
101 |
|
} |
102 |
|
|
104 |
|
* A new queue has unbounded capacity |
105 |
|
*/ |
106 |
|
public void testConstructor1() { |
107 |
< |
assertEquals(NOCAP, new PriorityBlockingQueue(SIZE).remainingCapacity()); |
107 |
> |
assertEquals(Integer.MAX_VALUE, |
108 |
> |
new PriorityBlockingQueue(SIZE).remainingCapacity()); |
109 |
|
} |
110 |
|
|
111 |
|
/** |
112 |
< |
* Constructor throws IAE if capacity argument nonpositive |
112 |
> |
* Constructor throws IllegalArgumentException if capacity argument nonpositive |
113 |
|
*/ |
114 |
|
public void testConstructor2() { |
115 |
|
try { |
116 |
< |
PriorityBlockingQueue q = new PriorityBlockingQueue(0); |
116 |
> |
new PriorityBlockingQueue(0); |
117 |
|
shouldThrow(); |
118 |
|
} catch (IllegalArgumentException success) {} |
119 |
|
} |
123 |
|
*/ |
124 |
|
public void testConstructor3() { |
125 |
|
try { |
126 |
< |
PriorityBlockingQueue q = new PriorityBlockingQueue(null); |
126 |
> |
new PriorityBlockingQueue(null); |
127 |
|
shouldThrow(); |
128 |
|
} catch (NullPointerException success) {} |
129 |
|
} |
132 |
|
* Initializing from Collection of null elements throws NPE |
133 |
|
*/ |
134 |
|
public void testConstructor4() { |
135 |
+ |
Collection<Integer> elements = Arrays.asList(new Integer[SIZE]); |
136 |
|
try { |
137 |
< |
Integer[] ints = new Integer[SIZE]; |
85 |
< |
PriorityBlockingQueue q = new PriorityBlockingQueue(Arrays.asList(ints)); |
137 |
> |
new PriorityBlockingQueue(elements); |
138 |
|
shouldThrow(); |
139 |
|
} catch (NullPointerException success) {} |
140 |
|
} |
143 |
|
* Initializing from Collection with some null elements throws NPE |
144 |
|
*/ |
145 |
|
public void testConstructor5() { |
146 |
+ |
Integer[] ints = new Integer[SIZE]; |
147 |
+ |
for (int i = 0; i < SIZE - 1; ++i) |
148 |
+ |
ints[i] = i; |
149 |
+ |
Collection<Integer> elements = Arrays.asList(ints); |
150 |
|
try { |
151 |
< |
Integer[] ints = new Integer[SIZE]; |
96 |
< |
for (int i = 0; i < SIZE-1; ++i) |
97 |
< |
ints[i] = new Integer(i); |
98 |
< |
PriorityBlockingQueue q = new PriorityBlockingQueue(Arrays.asList(ints)); |
151 |
> |
new PriorityBlockingQueue(elements); |
152 |
|
shouldThrow(); |
153 |
|
} catch (NullPointerException success) {} |
154 |
|
} |
159 |
|
public void testConstructor6() { |
160 |
|
Integer[] ints = new Integer[SIZE]; |
161 |
|
for (int i = 0; i < SIZE; ++i) |
162 |
< |
ints[i] = new Integer(i); |
162 |
> |
ints[i] = i; |
163 |
|
PriorityBlockingQueue q = new PriorityBlockingQueue(Arrays.asList(ints)); |
164 |
|
for (int i = 0; i < SIZE; ++i) |
165 |
|
assertEquals(ints[i], q.poll()); |
176 |
|
for (int i = 0; i < SIZE; ++i) |
177 |
|
ints[i] = new Integer(i); |
178 |
|
q.addAll(Arrays.asList(ints)); |
179 |
< |
for (int i = SIZE-1; i >= 0; --i) |
179 |
> |
for (int i = SIZE - 1; i >= 0; --i) |
180 |
|
assertEquals(ints[i], q.poll()); |
181 |
|
} |
182 |
|
|
186 |
|
public void testEmpty() { |
187 |
|
PriorityBlockingQueue q = new PriorityBlockingQueue(2); |
188 |
|
assertTrue(q.isEmpty()); |
189 |
< |
assertEquals(NOCAP, q.remainingCapacity()); |
189 |
> |
assertEquals(Integer.MAX_VALUE, q.remainingCapacity()); |
190 |
|
q.add(one); |
191 |
|
assertFalse(q.isEmpty()); |
192 |
|
q.add(two); |
196 |
|
} |
197 |
|
|
198 |
|
/** |
199 |
< |
* remainingCapacity does not change when elements added or removed, |
147 |
< |
* but size does |
199 |
> |
* remainingCapacity() always returns Integer.MAX_VALUE |
200 |
|
*/ |
201 |
|
public void testRemainingCapacity() { |
202 |
< |
PriorityBlockingQueue q = populatedQueue(SIZE); |
202 |
> |
BlockingQueue q = populatedQueue(SIZE); |
203 |
|
for (int i = 0; i < SIZE; ++i) { |
204 |
< |
assertEquals(NOCAP, q.remainingCapacity()); |
205 |
< |
assertEquals(SIZE-i, q.size()); |
206 |
< |
q.remove(); |
204 |
> |
assertEquals(Integer.MAX_VALUE, q.remainingCapacity()); |
205 |
> |
assertEquals(SIZE - i, q.size()); |
206 |
> |
assertEquals(i, q.remove()); |
207 |
|
} |
208 |
|
for (int i = 0; i < SIZE; ++i) { |
209 |
< |
assertEquals(NOCAP, q.remainingCapacity()); |
209 |
> |
assertEquals(Integer.MAX_VALUE, q.remainingCapacity()); |
210 |
|
assertEquals(i, q.size()); |
211 |
< |
q.add(new Integer(i)); |
211 |
> |
assertTrue(q.add(i)); |
212 |
|
} |
213 |
|
} |
214 |
|
|
215 |
|
/** |
164 |
– |
* offer(null) throws NPE |
165 |
– |
*/ |
166 |
– |
public void testOfferNull() { |
167 |
– |
try { |
168 |
– |
PriorityBlockingQueue q = new PriorityBlockingQueue(1); |
169 |
– |
q.offer(null); |
170 |
– |
shouldThrow(); |
171 |
– |
} catch (NullPointerException success) {} |
172 |
– |
} |
173 |
– |
|
174 |
– |
/** |
175 |
– |
* add(null) throws NPE |
176 |
– |
*/ |
177 |
– |
public void testAddNull() { |
178 |
– |
try { |
179 |
– |
PriorityBlockingQueue q = new PriorityBlockingQueue(1); |
180 |
– |
q.add(null); |
181 |
– |
shouldThrow(); |
182 |
– |
} catch (NullPointerException success) {} |
183 |
– |
} |
184 |
– |
|
185 |
– |
/** |
216 |
|
* Offer of comparable element succeeds |
217 |
|
*/ |
218 |
|
public void testOffer() { |
225 |
|
* Offer of non-Comparable throws CCE |
226 |
|
*/ |
227 |
|
public void testOfferNonComparable() { |
228 |
+ |
PriorityBlockingQueue q = new PriorityBlockingQueue(1); |
229 |
|
try { |
199 |
– |
PriorityBlockingQueue q = new PriorityBlockingQueue(1); |
200 |
– |
q.offer(new Object()); |
201 |
– |
q.offer(new Object()); |
230 |
|
q.offer(new Object()); |
231 |
|
shouldThrow(); |
232 |
< |
} catch (ClassCastException success) {} |
232 |
> |
} catch (ClassCastException success) { |
233 |
> |
assertTrue(q.isEmpty()); |
234 |
> |
assertEquals(0, q.size()); |
235 |
> |
assertNull(q.poll()); |
236 |
> |
} |
237 |
|
} |
238 |
|
|
239 |
|
/** |
248 |
|
} |
249 |
|
|
250 |
|
/** |
251 |
< |
* addAll(null) throws NPE |
220 |
< |
*/ |
221 |
< |
public void testAddAll1() { |
222 |
< |
try { |
223 |
< |
PriorityBlockingQueue q = new PriorityBlockingQueue(1); |
224 |
< |
q.addAll(null); |
225 |
< |
shouldThrow(); |
226 |
< |
} catch (NullPointerException success) {} |
227 |
< |
} |
228 |
< |
|
229 |
< |
/** |
230 |
< |
* addAll(this) throws IAE |
251 |
> |
* addAll(this) throws IllegalArgumentException |
252 |
|
*/ |
253 |
|
public void testAddAllSelf() { |
254 |
+ |
PriorityBlockingQueue q = populatedQueue(SIZE); |
255 |
|
try { |
234 |
– |
PriorityBlockingQueue q = populatedQueue(SIZE); |
256 |
|
q.addAll(q); |
257 |
|
shouldThrow(); |
258 |
|
} catch (IllegalArgumentException success) {} |
259 |
|
} |
260 |
|
|
261 |
|
/** |
241 |
– |
* addAll of a collection with null elements throws NPE |
242 |
– |
*/ |
243 |
– |
public void testAddAll2() { |
244 |
– |
try { |
245 |
– |
PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE); |
246 |
– |
Integer[] ints = new Integer[SIZE]; |
247 |
– |
q.addAll(Arrays.asList(ints)); |
248 |
– |
shouldThrow(); |
249 |
– |
} catch (NullPointerException success) {} |
250 |
– |
} |
251 |
– |
/** |
262 |
|
* addAll of a collection with any null elements throws NPE after |
263 |
|
* possibly adding some elements |
264 |
|
*/ |
265 |
|
public void testAddAll3() { |
266 |
+ |
PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE); |
267 |
+ |
Integer[] ints = new Integer[SIZE]; |
268 |
+ |
for (int i = 0; i < SIZE - 1; ++i) |
269 |
+ |
ints[i] = new Integer(i); |
270 |
|
try { |
257 |
– |
PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE); |
258 |
– |
Integer[] ints = new Integer[SIZE]; |
259 |
– |
for (int i = 0; i < SIZE-1; ++i) |
260 |
– |
ints[i] = new Integer(i); |
271 |
|
q.addAll(Arrays.asList(ints)); |
272 |
|
shouldThrow(); |
273 |
|
} catch (NullPointerException success) {} |
279 |
|
public void testAddAll5() { |
280 |
|
Integer[] empty = new Integer[0]; |
281 |
|
Integer[] ints = new Integer[SIZE]; |
282 |
< |
for (int i = SIZE-1; i >= 0; --i) |
282 |
> |
for (int i = SIZE - 1; i >= 0; --i) |
283 |
|
ints[i] = new Integer(i); |
284 |
|
PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE); |
285 |
|
assertFalse(q.addAll(Arrays.asList(empty))); |
289 |
|
} |
290 |
|
|
291 |
|
/** |
282 |
– |
* put(null) throws NPE |
283 |
– |
*/ |
284 |
– |
public void testPutNull() { |
285 |
– |
try { |
286 |
– |
PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE); |
287 |
– |
q.put(null); |
288 |
– |
shouldThrow(); |
289 |
– |
} catch (NullPointerException success) {} |
290 |
– |
} |
291 |
– |
|
292 |
– |
/** |
292 |
|
* all elements successfully put are contained |
293 |
|
*/ |
294 |
< |
public void testPut() { |
295 |
< |
PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE); |
296 |
< |
for (int i = 0; i < SIZE; ++i) { |
297 |
< |
Integer I = new Integer(i); |
298 |
< |
q.put(I); |
299 |
< |
assertTrue(q.contains(I)); |
300 |
< |
} |
301 |
< |
assertEquals(SIZE, q.size()); |
294 |
> |
public void testPut() { |
295 |
> |
PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE); |
296 |
> |
for (int i = 0; i < SIZE; ++i) { |
297 |
> |
Integer x = new Integer(i); |
298 |
> |
q.put(x); |
299 |
> |
assertTrue(q.contains(x)); |
300 |
> |
} |
301 |
> |
assertEquals(SIZE, q.size()); |
302 |
|
} |
303 |
|
|
304 |
|
/** |
307 |
|
public void testPutWithTake() throws InterruptedException { |
308 |
|
final PriorityBlockingQueue q = new PriorityBlockingQueue(2); |
309 |
|
final int size = 4; |
310 |
< |
Thread t = new Thread(new CheckedRunnable() { |
310 |
> |
Thread t = newStartedThread(new CheckedRunnable() { |
311 |
|
public void realRun() { |
312 |
|
for (int i = 0; i < size; i++) |
313 |
|
q.put(new Integer(0)); |
314 |
|
}}); |
315 |
|
|
316 |
< |
t.start(); |
317 |
< |
Thread.sleep(SHORT_DELAY_MS); |
319 |
< |
assertEquals(q.size(), size); |
316 |
> |
awaitTermination(t); |
317 |
> |
assertEquals(size, q.size()); |
318 |
|
q.take(); |
321 |
– |
t.interrupt(); |
322 |
– |
t.join(); |
319 |
|
} |
320 |
|
|
321 |
|
/** |
322 |
< |
* timed offer does not time out |
322 |
> |
* Queue is unbounded, so timed offer never times out |
323 |
|
*/ |
324 |
< |
public void testTimedOffer() throws InterruptedException { |
324 |
> |
public void testTimedOffer() { |
325 |
|
final PriorityBlockingQueue q = new PriorityBlockingQueue(2); |
326 |
< |
Thread t = new Thread(new Runnable() { |
327 |
< |
public void run() { |
328 |
< |
try { |
329 |
< |
q.put(new Integer(0)); |
330 |
< |
q.put(new Integer(0)); |
331 |
< |
threadAssertTrue(q.offer(new Integer(0), SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); |
332 |
< |
threadAssertTrue(q.offer(new Integer(0), LONG_DELAY_MS, TimeUnit.MILLISECONDS)); |
337 |
< |
} finally { } |
338 |
< |
} |
339 |
< |
}); |
326 |
> |
Thread t = newStartedThread(new CheckedRunnable() { |
327 |
> |
public void realRun() { |
328 |
> |
q.put(new Integer(0)); |
329 |
> |
q.put(new Integer(0)); |
330 |
> |
assertTrue(q.offer(new Integer(0), SHORT_DELAY_MS, MILLISECONDS)); |
331 |
> |
assertTrue(q.offer(new Integer(0), LONG_DELAY_MS, MILLISECONDS)); |
332 |
> |
}}); |
333 |
|
|
334 |
< |
t.start(); |
342 |
< |
Thread.sleep(SMALL_DELAY_MS); |
343 |
< |
t.interrupt(); |
344 |
< |
t.join(); |
334 |
> |
awaitTermination(t); |
335 |
|
} |
336 |
|
|
337 |
|
/** |
340 |
|
public void testTake() throws InterruptedException { |
341 |
|
PriorityBlockingQueue q = populatedQueue(SIZE); |
342 |
|
for (int i = 0; i < SIZE; ++i) { |
343 |
< |
assertEquals(i, ((Integer)q.take()).intValue()); |
343 |
> |
assertEquals(i, q.take()); |
344 |
|
} |
345 |
|
} |
346 |
|
|
347 |
|
/** |
358 |
– |
* take blocks interruptibly when empty |
359 |
– |
*/ |
360 |
– |
public void testTakeFromEmpty() throws InterruptedException { |
361 |
– |
final PriorityBlockingQueue q = new PriorityBlockingQueue(2); |
362 |
– |
Thread t = new Thread(new CheckedInterruptedRunnable() { |
363 |
– |
public void realRun() throws InterruptedException { |
364 |
– |
q.take(); |
365 |
– |
}}); |
366 |
– |
|
367 |
– |
t.start(); |
368 |
– |
Thread.sleep(SHORT_DELAY_MS); |
369 |
– |
t.interrupt(); |
370 |
– |
t.join(); |
371 |
– |
} |
372 |
– |
|
373 |
– |
/** |
348 |
|
* Take removes existing elements until empty, then blocks interruptibly |
349 |
|
*/ |
350 |
|
public void testBlockingTake() throws InterruptedException { |
351 |
< |
Thread t = new Thread(new CheckedInterruptedRunnable() { |
351 |
> |
final PriorityBlockingQueue q = populatedQueue(SIZE); |
352 |
> |
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
353 |
> |
Thread t = newStartedThread(new CheckedRunnable() { |
354 |
|
public void realRun() throws InterruptedException { |
355 |
< |
PriorityBlockingQueue q = populatedQueue(SIZE); |
356 |
< |
for (int i = 0; i < SIZE; ++i) { |
357 |
< |
threadAssertEquals(i, ((Integer)q.take()).intValue()); |
358 |
< |
} |
359 |
< |
q.take(); |
355 |
> |
for (int i = 0; i < SIZE; i++) assertEquals(i, q.take()); |
356 |
> |
|
357 |
> |
Thread.currentThread().interrupt(); |
358 |
> |
try { |
359 |
> |
q.take(); |
360 |
> |
shouldThrow(); |
361 |
> |
} catch (InterruptedException success) {} |
362 |
> |
assertFalse(Thread.interrupted()); |
363 |
> |
|
364 |
> |
pleaseInterrupt.countDown(); |
365 |
> |
try { |
366 |
> |
q.take(); |
367 |
> |
shouldThrow(); |
368 |
> |
} catch (InterruptedException success) {} |
369 |
> |
assertFalse(Thread.interrupted()); |
370 |
|
}}); |
371 |
|
|
372 |
< |
t.start(); |
373 |
< |
Thread.sleep(SHORT_DELAY_MS); |
372 |
> |
await(pleaseInterrupt); |
373 |
> |
if (randomBoolean()) assertThreadBlocks(t, Thread.State.WAITING); |
374 |
|
t.interrupt(); |
375 |
< |
t.join(); |
375 |
> |
awaitTermination(t); |
376 |
|
} |
377 |
|
|
392 |
– |
|
378 |
|
/** |
379 |
|
* poll succeeds unless empty |
380 |
|
*/ |
381 |
|
public void testPoll() { |
382 |
|
PriorityBlockingQueue q = populatedQueue(SIZE); |
383 |
|
for (int i = 0; i < SIZE; ++i) { |
384 |
< |
assertEquals(i, ((Integer)q.poll()).intValue()); |
384 |
> |
assertEquals(i, q.poll()); |
385 |
|
} |
386 |
< |
assertNull(q.poll()); |
386 |
> |
assertNull(q.poll()); |
387 |
|
} |
388 |
|
|
389 |
|
/** |
390 |
< |
* timed pool with zero timeout succeeds when non-empty, else times out |
390 |
> |
* timed poll with zero timeout succeeds when non-empty, else times out |
391 |
|
*/ |
392 |
|
public void testTimedPoll0() throws InterruptedException { |
393 |
|
PriorityBlockingQueue q = populatedQueue(SIZE); |
394 |
|
for (int i = 0; i < SIZE; ++i) { |
395 |
< |
assertEquals(i, ((Integer)q.poll(0, TimeUnit.MILLISECONDS)).intValue()); |
395 |
> |
assertEquals(i, q.poll(0, MILLISECONDS)); |
396 |
|
} |
397 |
< |
assertNull(q.poll(0, TimeUnit.MILLISECONDS)); |
397 |
> |
assertNull(q.poll(0, MILLISECONDS)); |
398 |
|
} |
399 |
|
|
400 |
|
/** |
401 |
< |
* timed pool with nonzero timeout succeeds when non-empty, else times out |
401 |
> |
* timed poll with nonzero timeout succeeds when non-empty, else times out |
402 |
|
*/ |
403 |
|
public void testTimedPoll() throws InterruptedException { |
404 |
< |
PriorityBlockingQueue q = populatedQueue(SIZE); |
404 |
> |
PriorityBlockingQueue<Integer> q = populatedQueue(SIZE); |
405 |
|
for (int i = 0; i < SIZE; ++i) { |
406 |
< |
assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); |
407 |
< |
} |
408 |
< |
assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); |
406 |
> |
long startTime = System.nanoTime(); |
407 |
> |
assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS)); |
408 |
> |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
409 |
> |
} |
410 |
> |
long startTime = System.nanoTime(); |
411 |
> |
assertNull(q.poll(timeoutMillis(), MILLISECONDS)); |
412 |
> |
assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); |
413 |
> |
checkEmpty(q); |
414 |
|
} |
415 |
|
|
416 |
|
/** |
418 |
|
* returning timeout status |
419 |
|
*/ |
420 |
|
public void testInterruptedTimedPoll() throws InterruptedException { |
421 |
< |
Thread t = new Thread(new CheckedRunnable() { |
421 |
> |
final BlockingQueue<Integer> q = populatedQueue(SIZE); |
422 |
> |
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
423 |
> |
Thread t = newStartedThread(new CheckedRunnable() { |
424 |
|
public void realRun() throws InterruptedException { |
425 |
< |
PriorityBlockingQueue q = populatedQueue(SIZE); |
426 |
< |
for (int i = 0; i < SIZE; ++i) { |
427 |
< |
threadAssertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue()); |
428 |
< |
} |
425 |
> |
for (int i = 0; i < SIZE; i++) |
426 |
> |
assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS)); |
427 |
> |
|
428 |
> |
Thread.currentThread().interrupt(); |
429 |
|
try { |
430 |
< |
q.poll(SMALL_DELAY_MS, TimeUnit.MILLISECONDS); |
431 |
< |
threadShouldThrow(); |
430 |
> |
q.poll(randomTimeout(), randomTimeUnit()); |
431 |
> |
shouldThrow(); |
432 |
|
} catch (InterruptedException success) {} |
433 |
< |
}}); |
442 |
< |
|
443 |
< |
t.start(); |
444 |
< |
Thread.sleep(SHORT_DELAY_MS); |
445 |
< |
t.interrupt(); |
446 |
< |
t.join(); |
447 |
< |
} |
433 |
> |
assertFalse(Thread.interrupted()); |
434 |
|
|
435 |
< |
/** |
450 |
< |
* timed poll before a delayed offer fails; after offer succeeds; |
451 |
< |
* on interruption throws |
452 |
< |
*/ |
453 |
< |
public void testTimedPollWithOffer() throws InterruptedException { |
454 |
< |
final PriorityBlockingQueue q = new PriorityBlockingQueue(2); |
455 |
< |
Thread t = new Thread(new CheckedRunnable() { |
456 |
< |
public void realRun() throws InterruptedException { |
457 |
< |
threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); |
458 |
< |
threadAssertEquals(0, q.poll(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS)); |
435 |
> |
pleaseInterrupt.countDown(); |
436 |
|
try { |
437 |
< |
q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS); |
438 |
< |
threadShouldThrow(); |
437 |
> |
q.poll(LONGER_DELAY_MS, MILLISECONDS); |
438 |
> |
shouldThrow(); |
439 |
|
} catch (InterruptedException success) {} |
440 |
+ |
assertFalse(Thread.interrupted()); |
441 |
|
}}); |
442 |
|
|
443 |
< |
t.start(); |
444 |
< |
Thread.sleep(SMALL_DELAY_MS); |
467 |
< |
assertTrue(q.offer(new Integer(0), SHORT_DELAY_MS, TimeUnit.MILLISECONDS)); |
443 |
> |
await(pleaseInterrupt); |
444 |
> |
if (randomBoolean()) assertThreadBlocks(t, Thread.State.TIMED_WAITING); |
445 |
|
t.interrupt(); |
446 |
< |
t.join(); |
446 |
> |
awaitTermination(t); |
447 |
|
} |
448 |
|
|
472 |
– |
|
449 |
|
/** |
450 |
|
* peek returns next element, or null if empty |
451 |
|
*/ |
452 |
|
public void testPeek() { |
453 |
|
PriorityBlockingQueue q = populatedQueue(SIZE); |
454 |
|
for (int i = 0; i < SIZE; ++i) { |
455 |
< |
assertEquals(i, ((Integer)q.peek()).intValue()); |
456 |
< |
q.poll(); |
455 |
> |
assertEquals(i, q.peek()); |
456 |
> |
assertEquals(i, q.poll()); |
457 |
|
assertTrue(q.peek() == null || |
458 |
< |
i != ((Integer)q.peek()).intValue()); |
458 |
> |
!q.peek().equals(i)); |
459 |
|
} |
460 |
< |
assertNull(q.peek()); |
460 |
> |
assertNull(q.peek()); |
461 |
|
} |
462 |
|
|
463 |
|
/** |
466 |
|
public void testElement() { |
467 |
|
PriorityBlockingQueue q = populatedQueue(SIZE); |
468 |
|
for (int i = 0; i < SIZE; ++i) { |
469 |
< |
assertEquals(i, ((Integer)q.element()).intValue()); |
470 |
< |
q.poll(); |
469 |
> |
assertEquals(i, q.element()); |
470 |
> |
assertEquals(i, q.poll()); |
471 |
|
} |
472 |
|
try { |
473 |
|
q.element(); |
481 |
|
public void testRemove() { |
482 |
|
PriorityBlockingQueue q = populatedQueue(SIZE); |
483 |
|
for (int i = 0; i < SIZE; ++i) { |
484 |
< |
assertEquals(i, ((Integer)q.remove()).intValue()); |
484 |
> |
assertEquals(i, q.remove()); |
485 |
|
} |
486 |
|
try { |
487 |
|
q.remove(); |
490 |
|
} |
491 |
|
|
492 |
|
/** |
517 |
– |
* remove(x) removes x and returns true if present |
518 |
– |
*/ |
519 |
– |
public void testRemoveElement() { |
520 |
– |
PriorityBlockingQueue q = populatedQueue(SIZE); |
521 |
– |
for (int i = 1; i < SIZE; i+=2) { |
522 |
– |
assertTrue(q.remove(new Integer(i))); |
523 |
– |
} |
524 |
– |
for (int i = 0; i < SIZE; i+=2) { |
525 |
– |
assertTrue(q.remove(new Integer(i))); |
526 |
– |
assertFalse(q.remove(new Integer(i+1))); |
527 |
– |
} |
528 |
– |
assertTrue(q.isEmpty()); |
529 |
– |
} |
530 |
– |
|
531 |
– |
/** |
493 |
|
* contains(x) reports true when elements added but not yet removed |
494 |
|
*/ |
495 |
|
public void testContains() { |
544 |
|
assertTrue(changed); |
545 |
|
|
546 |
|
assertTrue(q.containsAll(p)); |
547 |
< |
assertEquals(SIZE-i, q.size()); |
547 |
> |
assertEquals(SIZE - i, q.size()); |
548 |
|
p.remove(); |
549 |
|
} |
550 |
|
} |
557 |
|
PriorityBlockingQueue q = populatedQueue(SIZE); |
558 |
|
PriorityBlockingQueue p = populatedQueue(i); |
559 |
|
assertTrue(q.removeAll(p)); |
560 |
< |
assertEquals(SIZE-i, q.size()); |
560 |
> |
assertEquals(SIZE - i, q.size()); |
561 |
|
for (int j = 0; j < i; ++j) { |
562 |
< |
Integer I = (Integer)(p.remove()); |
563 |
< |
assertFalse(q.contains(I)); |
562 |
> |
Integer x = (Integer)(p.remove()); |
563 |
> |
assertFalse(q.contains(x)); |
564 |
|
} |
565 |
|
} |
566 |
|
} |
567 |
|
|
568 |
|
/** |
569 |
< |
* toArray contains all elements |
569 |
> |
* toArray contains all elements |
570 |
|
*/ |
571 |
|
public void testToArray() throws InterruptedException { |
572 |
|
PriorityBlockingQueue q = populatedQueue(SIZE); |
573 |
< |
Object[] o = q.toArray(); |
574 |
< |
Arrays.sort(o); |
575 |
< |
for (int i = 0; i < o.length; i++) |
576 |
< |
assertEquals(o[i], q.take()); |
573 |
> |
Object[] a = q.toArray(); |
574 |
> |
assertSame(Object[].class, a.getClass()); |
575 |
> |
Arrays.sort(a); |
576 |
> |
for (Object o : a) |
577 |
> |
assertSame(o, q.take()); |
578 |
> |
assertTrue(q.isEmpty()); |
579 |
|
} |
580 |
|
|
581 |
|
/** |
582 |
|
* toArray(a) contains all elements |
583 |
|
*/ |
584 |
|
public void testToArray2() throws InterruptedException { |
585 |
< |
PriorityBlockingQueue q = populatedQueue(SIZE); |
586 |
< |
Integer[] ints = new Integer[SIZE]; |
587 |
< |
ints = (Integer[])q.toArray(ints); |
585 |
> |
PriorityBlockingQueue<Integer> q = populatedQueue(SIZE); |
586 |
> |
Integer[] ints = new Integer[SIZE]; |
587 |
> |
Integer[] array = q.toArray(ints); |
588 |
> |
assertSame(ints, array); |
589 |
|
Arrays.sort(ints); |
590 |
< |
for (int i = 0; i < ints.length; i++) |
591 |
< |
assertEquals(ints[i], q.take()); |
592 |
< |
} |
629 |
< |
|
630 |
< |
/** |
631 |
< |
* toArray(null) throws NPE |
632 |
< |
*/ |
633 |
< |
public void testToArray_BadArg() { |
634 |
< |
try { |
635 |
< |
PriorityBlockingQueue q = populatedQueue(SIZE); |
636 |
< |
Object o[] = q.toArray(null); |
637 |
< |
shouldThrow(); |
638 |
< |
} catch (NullPointerException success) {} |
590 |
> |
for (Integer o : ints) |
591 |
> |
assertSame(o, q.take()); |
592 |
> |
assertTrue(q.isEmpty()); |
593 |
|
} |
594 |
|
|
595 |
|
/** |
596 |
< |
* toArray with incompatible array type throws CCE |
596 |
> |
* toArray(incompatible array type) throws ArrayStoreException |
597 |
|
*/ |
598 |
|
public void testToArray1_BadArg() { |
599 |
< |
try { |
600 |
< |
PriorityBlockingQueue q = populatedQueue(SIZE); |
601 |
< |
Object o[] = q.toArray(new String[10] ); |
602 |
< |
shouldThrow(); |
603 |
< |
} catch (ArrayStoreException success) {} |
599 |
> |
PriorityBlockingQueue q = populatedQueue(SIZE); |
600 |
> |
try { |
601 |
> |
q.toArray(new String[10]); |
602 |
> |
shouldThrow(); |
603 |
> |
} catch (ArrayStoreException success) {} |
604 |
|
} |
605 |
|
|
606 |
|
/** |
608 |
|
*/ |
609 |
|
public void testIterator() { |
610 |
|
PriorityBlockingQueue q = populatedQueue(SIZE); |
611 |
< |
int i = 0; |
612 |
< |
Iterator it = q.iterator(); |
613 |
< |
while (it.hasNext()) { |
611 |
> |
Iterator it = q.iterator(); |
612 |
> |
int i; |
613 |
> |
for (i = 0; it.hasNext(); i++) |
614 |
|
assertTrue(q.contains(it.next())); |
661 |
– |
++i; |
662 |
– |
} |
615 |
|
assertEquals(i, SIZE); |
616 |
+ |
assertIteratorExhausted(it); |
617 |
+ |
} |
618 |
+ |
|
619 |
+ |
/** |
620 |
+ |
* iterator of empty collection has no elements |
621 |
+ |
*/ |
622 |
+ |
public void testEmptyIterator() { |
623 |
+ |
assertIteratorExhausted(new PriorityBlockingQueue().iterator()); |
624 |
|
} |
625 |
|
|
626 |
|
/** |
627 |
|
* iterator.remove removes current element |
628 |
|
*/ |
629 |
< |
public void testIteratorRemove () { |
629 |
> |
public void testIteratorRemove() { |
630 |
|
final PriorityBlockingQueue q = new PriorityBlockingQueue(3); |
631 |
|
q.add(new Integer(2)); |
632 |
|
q.add(new Integer(1)); |
642 |
|
assertFalse(it.hasNext()); |
643 |
|
} |
644 |
|
|
685 |
– |
|
645 |
|
/** |
646 |
|
* toString contains toStrings of elements |
647 |
|
*/ |
649 |
|
PriorityBlockingQueue q = populatedQueue(SIZE); |
650 |
|
String s = q.toString(); |
651 |
|
for (int i = 0; i < SIZE; ++i) { |
652 |
< |
assertTrue(s.indexOf(String.valueOf(i)) >= 0); |
652 |
> |
assertTrue(s.contains(String.valueOf(i))); |
653 |
|
} |
654 |
|
} |
655 |
|
|
656 |
|
/** |
657 |
< |
* offer transfers elements across Executor tasks |
657 |
> |
* timed poll transfers elements across Executor tasks |
658 |
|
*/ |
659 |
|
public void testPollInExecutor() { |
660 |
|
final PriorityBlockingQueue q = new PriorityBlockingQueue(2); |
661 |
< |
ExecutorService executor = Executors.newFixedThreadPool(2); |
662 |
< |
executor.execute(new CheckedRunnable() { |
663 |
< |
public void realRun() throws InterruptedException { |
664 |
< |
threadAssertNull(q.poll()); |
665 |
< |
threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS)); |
666 |
< |
threadAssertTrue(q.isEmpty()); |
667 |
< |
}}); |
668 |
< |
|
669 |
< |
executor.execute(new CheckedRunnable() { |
670 |
< |
public void realRun() throws InterruptedException { |
671 |
< |
Thread.sleep(SMALL_DELAY_MS); |
672 |
< |
q.put(new Integer(1)); |
673 |
< |
}}); |
674 |
< |
|
675 |
< |
joinPool(executor); |
661 |
> |
final CheckedBarrier threadsStarted = new CheckedBarrier(2); |
662 |
> |
final ExecutorService executor = Executors.newFixedThreadPool(2); |
663 |
> |
try (PoolCleaner cleaner = cleaner(executor)) { |
664 |
> |
executor.execute(new CheckedRunnable() { |
665 |
> |
public void realRun() throws InterruptedException { |
666 |
> |
assertNull(q.poll()); |
667 |
> |
threadsStarted.await(); |
668 |
> |
assertSame(one, q.poll(LONG_DELAY_MS, MILLISECONDS)); |
669 |
> |
checkEmpty(q); |
670 |
> |
}}); |
671 |
> |
|
672 |
> |
executor.execute(new CheckedRunnable() { |
673 |
> |
public void realRun() throws InterruptedException { |
674 |
> |
threadsStarted.await(); |
675 |
> |
q.put(one); |
676 |
> |
}}); |
677 |
> |
} |
678 |
|
} |
679 |
|
|
680 |
|
/** |
681 |
< |
* A deserialized serialized queue has same elements |
681 |
> |
* A deserialized/reserialized queue has same elements |
682 |
|
*/ |
683 |
|
public void testSerialization() throws Exception { |
684 |
< |
PriorityBlockingQueue q = populatedQueue(SIZE); |
685 |
< |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
725 |
< |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
726 |
< |
out.writeObject(q); |
727 |
< |
out.close(); |
728 |
< |
|
729 |
< |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
730 |
< |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
731 |
< |
PriorityBlockingQueue r = (PriorityBlockingQueue)in.readObject(); |
732 |
< |
assertEquals(q.size(), r.size()); |
733 |
< |
while (!q.isEmpty()) |
734 |
< |
assertEquals(q.remove(), r.remove()); |
735 |
< |
} |
684 |
> |
Queue x = populatedQueue(SIZE); |
685 |
> |
Queue y = serialClone(x); |
686 |
|
|
687 |
< |
/** |
688 |
< |
* drainTo(null) throws NPE |
689 |
< |
*/ |
690 |
< |
public void testDrainToNull() { |
691 |
< |
PriorityBlockingQueue q = populatedQueue(SIZE); |
692 |
< |
try { |
693 |
< |
q.drainTo(null); |
744 |
< |
shouldThrow(); |
745 |
< |
} catch (NullPointerException success) {} |
746 |
< |
} |
747 |
< |
|
748 |
< |
/** |
749 |
< |
* drainTo(this) throws IAE |
750 |
< |
*/ |
751 |
< |
public void testDrainToSelf() { |
752 |
< |
PriorityBlockingQueue q = populatedQueue(SIZE); |
753 |
< |
try { |
754 |
< |
q.drainTo(q); |
755 |
< |
shouldThrow(); |
756 |
< |
} catch (IllegalArgumentException success) {} |
687 |
> |
assertNotSame(x, y); |
688 |
> |
assertEquals(x.size(), y.size()); |
689 |
> |
while (!x.isEmpty()) { |
690 |
> |
assertFalse(y.isEmpty()); |
691 |
> |
assertEquals(x.remove(), y.remove()); |
692 |
> |
} |
693 |
> |
assertTrue(y.isEmpty()); |
694 |
|
} |
695 |
|
|
696 |
|
/** |
700 |
|
PriorityBlockingQueue q = populatedQueue(SIZE); |
701 |
|
ArrayList l = new ArrayList(); |
702 |
|
q.drainTo(l); |
703 |
< |
assertEquals(q.size(), 0); |
704 |
< |
assertEquals(l.size(), SIZE); |
703 |
> |
assertEquals(0, q.size()); |
704 |
> |
assertEquals(SIZE, l.size()); |
705 |
|
for (int i = 0; i < SIZE; ++i) |
706 |
|
assertEquals(l.get(i), new Integer(i)); |
707 |
|
q.add(zero); |
711 |
|
assertTrue(q.contains(one)); |
712 |
|
l.clear(); |
713 |
|
q.drainTo(l); |
714 |
< |
assertEquals(q.size(), 0); |
715 |
< |
assertEquals(l.size(), 2); |
714 |
> |
assertEquals(0, q.size()); |
715 |
> |
assertEquals(2, l.size()); |
716 |
|
for (int i = 0; i < 2; ++i) |
717 |
|
assertEquals(l.get(i), new Integer(i)); |
718 |
|
} |
724 |
|
final PriorityBlockingQueue q = populatedQueue(SIZE); |
725 |
|
Thread t = new Thread(new CheckedRunnable() { |
726 |
|
public void realRun() { |
727 |
< |
q.put(new Integer(SIZE+1)); |
727 |
> |
q.put(new Integer(SIZE + 1)); |
728 |
|
}}); |
729 |
|
|
730 |
|
t.start(); |
738 |
|
} |
739 |
|
|
740 |
|
/** |
741 |
< |
* drainTo(null, n) throws NPE |
805 |
< |
*/ |
806 |
< |
public void testDrainToNullN() { |
807 |
< |
PriorityBlockingQueue q = populatedQueue(SIZE); |
808 |
< |
try { |
809 |
< |
q.drainTo(null, 0); |
810 |
< |
shouldThrow(); |
811 |
< |
} catch (NullPointerException success) {} |
812 |
< |
} |
813 |
< |
|
814 |
< |
/** |
815 |
< |
* drainTo(this, n) throws IAE |
816 |
< |
*/ |
817 |
< |
public void testDrainToSelfN() { |
818 |
< |
PriorityBlockingQueue q = populatedQueue(SIZE); |
819 |
< |
try { |
820 |
< |
q.drainTo(q, 0); |
821 |
< |
shouldThrow(); |
822 |
< |
} catch (IllegalArgumentException success) {} |
823 |
< |
} |
824 |
< |
|
825 |
< |
/** |
826 |
< |
* drainTo(c, n) empties first max {n, size} elements of queue into c |
741 |
> |
* drainTo(c, n) empties first min(n, size) elements of queue into c |
742 |
|
*/ |
743 |
|
public void testDrainToN() { |
744 |
< |
PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE*2); |
744 |
> |
PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE * 2); |
745 |
|
for (int i = 0; i < SIZE + 2; ++i) { |
746 |
|
for (int j = 0; j < SIZE; j++) |
747 |
|
assertTrue(q.offer(new Integer(j))); |
748 |
|
ArrayList l = new ArrayList(); |
749 |
|
q.drainTo(l, i); |
750 |
< |
int k = (i < SIZE)? i : SIZE; |
751 |
< |
assertEquals(l.size(), k); |
752 |
< |
assertEquals(q.size(), SIZE-k); |
750 |
> |
int k = (i < SIZE) ? i : SIZE; |
751 |
> |
assertEquals(k, l.size()); |
752 |
> |
assertEquals(SIZE - k, q.size()); |
753 |
|
for (int j = 0; j < k; ++j) |
754 |
|
assertEquals(l.get(j), new Integer(j)); |
755 |
< |
while (q.poll() != null) ; |
755 |
> |
do {} while (q.poll() != null); |
756 |
> |
} |
757 |
> |
} |
758 |
> |
|
759 |
> |
/** |
760 |
> |
* remove(null), contains(null) always return false |
761 |
> |
*/ |
762 |
> |
public void testNeverContainsNull() { |
763 |
> |
Collection<?>[] qs = { |
764 |
> |
new PriorityBlockingQueue<Object>(), |
765 |
> |
populatedQueue(2), |
766 |
> |
}; |
767 |
> |
|
768 |
> |
for (Collection<?> q : qs) { |
769 |
> |
assertFalse(q.contains(null)); |
770 |
> |
assertFalse(q.remove(null)); |
771 |
|
} |
772 |
|
} |
773 |
|
|