-
Bug
-
Resolution: Duplicate
-
P4
-
7, 8u20, 9
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8142177 | emb-9 | Doug Lea | P4 | Resolved | Fixed | team |
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.
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.
- backported by
-
JDK-8142177 FutureTask.isDone returns true when task has not yet completed
- Resolved
- duplicates
-
JDK-8134853 Bulk integration of java.util.concurrent and related java.util classes
- Resolved