Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8102407

updateProgress should be more generous with illegal values

    Details

    • Subcomponent:

      Description

      The updateProgress methods of Task are spec'd such that the workDone must be less than or equal to max, or an IllegalArgumentException is thrown. This is sometimes a pain. The following Service would sometimes throw an exception based on timing where the "delta" ended up being 1 more than max:


                      final Service<Void> service = new Service<Void>() {
                          final Service<Void> svc = this;
                          @Override protected Task<Void> createTask() {
                              return new Task<Void>() {
                                  @Override protected Void call() throws Exception {
                                      long millis = 1000;
                                      long start = System.currentTimeMillis();
                                      long delta = 0;
                                      while (delta < millis) {
                                          delta = System.currentTimeMillis() - start;
                                          Thread.sleep(1);
                                          updateProgress(delta, millis);
                                      }
                                      return null;
                                  }
                              };
                          }
                      };


      Instead, lets just spec that a call to updateProgress where workDown > max will be clamped to max.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rbair Richard Bair
                Reporter:
                rbair Richard Bair
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported: