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

Task when cancelled still updates progress and value

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: fx2.0
    • Fix Version/s: fx2.1
    • Component/s: javafx
    • Labels:
      None

      Description

      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.

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:
              Imported: