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

FutureTask.isDone returns true when task has not yet completed

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 7, 8u20, 9
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:

      Backports

        Description

        FULL PRODUCT VERSION :


        ADDITIONAL OS VERSION INFORMATION :
        really doesn't matter :P

        A DESCRIPTION OF THE PROBLEM :
        implementation of FutureTask#isDone is as follows :

        public boolean isDone() {
                return state != NEW;
        }

        while it should be as follows :

        public boolean isDone(){
                 return state != NEW && state != COMPLETING && state != INTERRUPTING;
        }

        or (less code, but less readable):

        public boolean isDone(){
                 return state > COMPLETING && state != INTERRUPTING;
        }

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        open sources, go to FutureTask#isDone implementation, read javadoc of Future interface, look at them.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        either

        public boolean isDone(){
                 return state != NEW && state != COMPLETING && state != INTERRUPTING;
        }

        or:

        public boolean isDone(){
                 return state > COMPLETING && state != INTERRUPTING;
        }
        ACTUAL -
        public boolean isDone() {
                return state != NEW;
        }

        REPRODUCIBILITY :
        This bug can be reproduced always.

        CUSTOMER SUBMITTED WORKAROUND :
        Write your own RunnableFuture implementation with long javadoc explaining.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                martin Martin Buchholz
                Reporter:
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                9 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: