JDK-6269146 : Cancelled FutureTask's interrupt bit not always set
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.concurrent
  • Affected Version: 6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2005-05-12
  • Updated: 2010-04-02
  • Resolved: 2005-09-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
JDK 6
6 b51Fixed
Description
Doug Lea writes:

"As kindly pointed out by Tom May (Joe's ex-colleague), there
was a window in FutureTask, where a task that was not cancelled
soon enough to cause it not to be started still didn't set
that task's interrupt status (if mayInterrupt true), as it should
have according to spec."
###@###.### 2005-05-12 00:52:22 GMT

Comments
SUGGESTED FIX --- FutureTask.java 2 May 2005 18:38:53 -0000 1.35 +++ FutureTask.java 12 May 2005 00:12:38 -0000 1.37 @@ -265,7 +265,10 @@ return; try { runner = Thread.currentThread(); - innerSet(callable.call()); + if (getState() == RUNNING) // recheck after setting thread + innerSet(callable.call()); + else + releaseShared(0); // cancel } catch (Throwable ex) { innerSetException(ex); } @@ -276,7 +279,8 @@ return false; try { runner = Thread.currentThread(); - callable.call(); // don't set result + if (getState() == RUNNING) + callable.call(); // don't set result runner = null; return compareAndSetState(RUNNING, 0); } catch (Throwable ex) { ###@###.### 2005-05-12 01:05:47 GMT
2005-05-12

EVALUATION Part of jsr166x project ###@###.### 2005-05-12 01:05:46 GMT
2005-05-12