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

Comparing jsr166/src/test/tck/ScheduledExecutorTest.java (file contents):
Revision 1.98 by jsr166, Fri Sep 6 18:43:35 2019 UTC vs.
Revision 1.99 by dl, Tue Jan 26 13:33:06 2021 UTC

# Line 66 | Line 66 | public class ScheduledExecutorTest exten
66          try (PoolCleaner cleaner = cleaner(p)) {
67              final long startTime = System.nanoTime();
68              final CountDownLatch done = new CountDownLatch(1);
69 <            Callable task = new CheckedCallable<Boolean>() {
69 >            Callable<Boolean> task = new CheckedCallable<Boolean>() {
70                  public Boolean realCall() {
71                      done.countDown();
72                      assertTrue(millisElapsedSince(startTime) >= timeoutMillis());
73                      return Boolean.TRUE;
74                  }};
75 <            Future f = p.schedule(task, timeoutMillis(), MILLISECONDS);
75 >            Future<Boolean> f = p.schedule(task, timeoutMillis(), MILLISECONDS);
76              assertSame(Boolean.TRUE, f.get());
77              assertTrue(millisElapsedSince(startTime) >= timeoutMillis());
78              assertEquals(0L, done.getCount());
# Line 92 | Line 92 | public class ScheduledExecutorTest exten
92                      done.countDown();
93                      assertTrue(millisElapsedSince(startTime) >= timeoutMillis());
94                  }};
95 <            Future f = p.schedule(task, timeoutMillis(), MILLISECONDS);
95 >            Future<?> f = p.schedule(task, timeoutMillis(), MILLISECONDS);
96              await(done);
97              assertNull(f.get(LONG_DELAY_MS, MILLISECONDS));
98              assertTrue(millisElapsedSince(startTime) >= timeoutMillis());
# Line 112 | Line 112 | public class ScheduledExecutorTest exten
112                      done.countDown();
113                      assertTrue(millisElapsedSince(startTime) >= timeoutMillis());
114                  }};
115 <            ScheduledFuture f =
115 >            ScheduledFuture<?> f =
116                  p.scheduleAtFixedRate(task, timeoutMillis(),
117                                        LONG_DELAY_MS, MILLISECONDS);
118              await(done);
# Line 134 | Line 134 | public class ScheduledExecutorTest exten
134                      done.countDown();
135                      assertTrue(millisElapsedSince(startTime) >= timeoutMillis());
136                  }};
137 <            ScheduledFuture f =
137 >            ScheduledFuture<?> f =
138                  p.scheduleWithFixedDelay(task, timeoutMillis(),
139                                           LONG_DELAY_MS, MILLISECONDS);
140              await(done);
# Line 162 | Line 162 | public class ScheduledExecutorTest exten
162                  final CountDownLatch done = new CountDownLatch(cycles);
163                  final Runnable task = new CheckedRunnable() {
164                      public void realRun() { done.countDown(); }};
165 <                final ScheduledFuture periodicTask =
165 >                final ScheduledFuture<?> periodicTask =
166                      p.scheduleAtFixedRate(task, 0, delay, MILLISECONDS);
167                  final int totalDelayMillis = (cycles - 1) * delay;
168                  await(done, totalDelayMillis + LONG_DELAY_MS);
# Line 208 | Line 208 | public class ScheduledExecutorTest exten
208                          previous.set(now);
209                          done.countDown();
210                      }};
211 <                final ScheduledFuture periodicTask =
211 >                final ScheduledFuture<?> periodicTask =
212                      p.scheduleWithFixedDelay(task, 0, delay, MILLISECONDS);
213                  final int totalDelayMillis = (cycles - 1) * delay;
214                  await(done, totalDelayMillis + cycles * LONG_DELAY_MS);
# Line 549 | Line 549 | public class ScheduledExecutorTest exten
549          final ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
550          try (PoolCleaner cleaner = cleaner(p, done)) {
551              final CountDownLatch threadStarted = new CountDownLatch(1);
552 <            ScheduledFuture[] tasks = new ScheduledFuture[5];
552 >            @SuppressWarnings("unchecked")
553 >            ScheduledFuture<?>[] tasks = (ScheduledFuture<?>[])new ScheduledFuture[5];
554              for (int i = 0; i < tasks.length; i++) {
555                  Runnable r = new CheckedRunnable() {
556                      public void realRun() throws InterruptedException {
# Line 572 | Line 573 | public class ScheduledExecutorTest exten
573          final CountDownLatch done = new CountDownLatch(1);
574          final ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
575          try (PoolCleaner cleaner = cleaner(p, done)) {
576 <            ScheduledFuture[] tasks = new ScheduledFuture[5];
576 >            @SuppressWarnings("unchecked")
577 >            ScheduledFuture<?>[] tasks = (ScheduledFuture<?>[])new ScheduledFuture[5];
578              final CountDownLatch threadStarted = new CountDownLatch(1);
579              for (int i = 0; i < tasks.length; i++) {
580                  Runnable r = new CheckedRunnable() {
# Line 600 | Line 602 | public class ScheduledExecutorTest exten
602       * purge eventually removes cancelled tasks from the queue
603       */
604      public void testPurge() throws InterruptedException {
605 <        final ScheduledFuture[] tasks = new ScheduledFuture[5];
605 >        @SuppressWarnings("unchecked")
606 >        ScheduledFuture<?>[] tasks = (ScheduledFuture<?>[])new ScheduledFuture[5];
607          final Runnable releaser = new Runnable() { public void run() {
608 <            for (ScheduledFuture task : tasks)
608 >            for (ScheduledFuture<?> task : tasks)
609                  if (task != null) task.cancel(true); }};
610          final ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
611          try (PoolCleaner cleaner = cleaner(p, releaser)) {
# Line 669 | Line 672 | public class ScheduledExecutorTest exten
672       */
673      public void testShutdownNow_delayedTasks() throws InterruptedException {
674          final ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
675 <        List<ScheduledFuture> tasks = new ArrayList<>();
675 >        List<ScheduledFuture<?>> tasks = new ArrayList<>();
676          for (int i = 0; i < 3; i++) {
677              Runnable r = new NoOpRunnable();
678              tasks.add(p.schedule(r, 9, SECONDS));
# Line 677 | Line 680 | public class ScheduledExecutorTest exten
680              tasks.add(p.scheduleWithFixedDelay(r, 9, 9, SECONDS));
681          }
682          if (testImplementationDetails)
683 <            assertEquals(new HashSet(tasks), new HashSet(p.getQueue()));
683 >            assertEquals(new HashSet<Object>(tasks), new HashSet<Object>(p.getQueue()));
684          final List<Runnable> queuedTasks;
685          try {
686              queuedTasks = p.shutdownNow();
# Line 687 | Line 690 | public class ScheduledExecutorTest exten
690          assertTrue(p.isShutdown());
691          assertTrue(p.getQueue().isEmpty());
692          if (testImplementationDetails)
693 <            assertEquals(new HashSet(tasks), new HashSet(queuedTasks));
693 >            assertEquals(new HashSet<Object>(tasks), new HashSet<Object>(queuedTasks));
694          assertEquals(tasks.size(), queuedTasks.size());
695 <        for (ScheduledFuture task : tasks) {
695 >        for (ScheduledFuture<?> task : tasks) {
696              assertFalse(task.isDone());
697              assertFalse(task.isCancelled());
698          }
# Line 1288 | Line 1291 | public class ScheduledExecutorTest exten
1291                      p.invokeAll(tasks, timeout, MILLISECONDS);
1292                  assertEquals(tasks.size(), futures.size());
1293                  assertTrue(millisElapsedSince(startTime) >= timeout);
1294 <                for (Future future : futures)
1294 >                for (Future<?> future : futures)
1295                      assertTrue(future.isDone());
1296                  assertTrue(futures.get(1).isCancelled());
1297                  try {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines