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

FutureTask.isDone returns true when task has not yet completed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • 9
    • 7, 8u20, 9
    • core-libs

        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.

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

                Created:
                Updated:
                Resolved: