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

Task when cancelled still updates progress and value

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • fx2.1
    • fx2.0
    • javafx
    • None

      After calling cancel() or cancel(true) on a Task, the task will still update its progress and value at completion.

      --

      There are two scenarios here. Consider a long-running computation that returns a list of data as its value. When you say "cancel" the task, you might want to either 1) stop the task and discard any partial result or 2) stop the task and retain the partial result.

      At least: there should ways to accomplish both.

      The way it works now is compatible with 2). I propose that this behaviour remains, but available through a new method "cancelWithValue()" (or similar). Here it is assumed that the user code will actually be checking thread interruption, ending its computation and making available the partial results.

      The proposed fix for the original cancel() method should thus be compatible with scenario 1). I.e., when cancelled, don't update progress and value, regardless of what the user code might do.

            rbair Richard Bair (Inactive)
            kvedaajfx Knut Arne Vedaa (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: