ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/ExecutorsTest.java
(Generate patch)

Comparing jsr166/src/test/tck/ExecutorsTest.java (file contents):
Revision 1.51 by jsr166, Mon Dec 16 22:55:54 2019 UTC vs.
Revision 1.55 by dl, Tue Jan 26 13:33:06 2021 UTC

# Line 206 | Line 206 | public class ExecutorsTest extends JSR16
206                      await(proceed);
207                  }};
208              long startTime = System.nanoTime();
209 <            Future f = p.schedule(Executors.callable(task, Boolean.TRUE),
209 >            Future<?> f = p.schedule(Executors.callable(task, Boolean.TRUE),
210                                    timeoutMillis(), MILLISECONDS);
211              assertFalse(f.isDone());
212              proceed.countDown();
# Line 230 | Line 230 | public class ExecutorsTest extends JSR16
230                      await(proceed);
231                  }};
232              long startTime = System.nanoTime();
233 <            Future f = p.schedule(Executors.callable(task, Boolean.TRUE),
233 >            Future<?> f = p.schedule(Executors.callable(task, Boolean.TRUE),
234                                    timeoutMillis(), MILLISECONDS);
235              assertFalse(f.isDone());
236              proceed.countDown();
# Line 256 | Line 256 | public class ExecutorsTest extends JSR16
256                      await(proceed);
257                  }};
258              long startTime = System.nanoTime();
259 <            Future f = p.schedule(Executors.callable(task, Boolean.TRUE),
259 >            Future<?> f = p.schedule(Executors.callable(task, Boolean.TRUE),
260                                    timeoutMillis(), MILLISECONDS);
261              assertFalse(f.isDone());
262              proceed.countDown();
# Line 279 | Line 279 | public class ExecutorsTest extends JSR16
279              Executors.newScheduledThreadPool(2),
280          };
281  
282 <        final Runnable sleeper = new CheckedInterruptedRunnable() {
282 >        final CountDownLatch done = new CountDownLatch(1);
283 >
284 >        final Runnable sleeper = new CheckedRunnable() {
285              public void realRun() throws InterruptedException {
286 <                delay(LONG_DELAY_MS);
286 >                done.await(LONG_DELAY_MS, MILLISECONDS);
287              }};
288  
289          List<Thread> threads = new ArrayList<>();
290          for (final ExecutorService executor : executors) {
291              threads.add(newStartedThread(new CheckedRunnable() {
292                  public void realRun() {
293 <                    Future future = executor.submit(sleeper);
293 >                    Future<?> future = executor.submit(sleeper);
294                      assertFutureTimesOut(future);
295                  }}));
296          }
297          for (Thread thread : threads)
298              awaitTermination(thread);
299 +        done.countDown();
300          for (ExecutorService executor : executors)
301              joinPool(executor);
302      }
# Line 439 | Line 442 | public class ExecutorsTest extends JSR16
442              public void realRun() throws Exception {
443                  if (System.getSecurityManager() == null)
444                      return;
445 <                Callable task = Executors.privilegedCallable(new CheckCCL());
445 >                Callable<?> task = Executors.privilegedCallable(new CheckCCL());
446                  try {
447                      task.call();
448                      shouldThrow();
# Line 518 | Line 521 | public class ExecutorsTest extends JSR16
521       * callable(Runnable) returns null when called
522       */
523      public void testCallable1() throws Exception {
524 <        Callable c = Executors.callable(new NoOpRunnable());
524 >        Callable<?> c = Executors.callable(new NoOpRunnable());
525          assertNull(c.call());
526      }
527  
# Line 526 | Line 529 | public class ExecutorsTest extends JSR16
529       * callable(Runnable, result) returns result when called
530       */
531      public void testCallable2() throws Exception {
532 <        Callable c = Executors.callable(new NoOpRunnable(), one);
532 >        Callable<?> c = Executors.callable(new NoOpRunnable(), one);
533          assertSame(one, c.call());
534      }
535  
# Line 534 | Line 537 | public class ExecutorsTest extends JSR16
537       * callable(PrivilegedAction) returns its result when called
538       */
539      public void testCallable3() throws Exception {
540 <        Callable c = Executors.callable(new PrivilegedAction() {
540 >        Callable<?> c = Executors.callable(new PrivilegedAction() {
541                  public Object run() { return one; }});
542          assertSame(one, c.call());
543      }
# Line 543 | Line 546 | public class ExecutorsTest extends JSR16
546       * callable(PrivilegedExceptionAction) returns its result when called
547       */
548      public void testCallable4() throws Exception {
549 <        Callable c = Executors.callable(new PrivilegedExceptionAction() {
549 >        Callable<?> c = Executors.callable(new PrivilegedExceptionAction() {
550                  public Object run() { return one; }});
551          assertSame(one, c.call());
552      }
# Line 553 | Line 556 | public class ExecutorsTest extends JSR16
556       */
557      public void testCallableNPE1() {
558          try {
559 <            Callable unused = Executors.callable((Runnable) null);
559 >            Callable<?> unused = Executors.callable((Runnable) null);
560              shouldThrow();
561          } catch (NullPointerException success) {}
562      }
# Line 563 | Line 566 | public class ExecutorsTest extends JSR16
566       */
567      public void testCallableNPE2() {
568          try {
569 <            Callable unused = Executors.callable((Runnable) null, one);
569 >            Callable<?> unused = Executors.callable((Runnable) null, one);
570              shouldThrow();
571          } catch (NullPointerException success) {}
572      }
# Line 573 | Line 576 | public class ExecutorsTest extends JSR16
576       */
577      public void testCallableNPE3() {
578          try {
579 <            Callable unused = Executors.callable((PrivilegedAction) null);
579 >            Callable<?> unused = Executors.callable((PrivilegedAction) null);
580              shouldThrow();
581          } catch (NullPointerException success) {}
582      }
# Line 583 | Line 586 | public class ExecutorsTest extends JSR16
586       */
587      public void testCallableNPE4() {
588          try {
589 <            Callable unused = Executors.callable((PrivilegedExceptionAction) null);
589 >            Callable<?> unused = Executors.callable((PrivilegedExceptionAction) null);
590              shouldThrow();
591          } catch (NullPointerException success) {}
592      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines