Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 68250 invoked from network); 3 Sep 2009 12:35:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 3 Sep 2009 12:35:21 -0000 Received: (qmail 6427 invoked by uid 500); 3 Sep 2009 12:35:21 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 6399 invoked by uid 500); 3 Sep 2009 12:35:21 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 6390 invoked by uid 99); 3 Sep 2009 12:35:21 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Sep 2009 12:35:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Sep 2009 12:35:18 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 8CCE0234C004 for ; Thu, 3 Sep 2009 05:34:57 -0700 (PDT) Message-ID: <293145490.1251981297565.JavaMail.jira@brutus> Date: Thu, 3 Sep 2009 05:34:57 -0700 (PDT) From: "Tim Ellison (JIRA)" To: commits@harmony.apache.org Subject: [jira] Closed: (HARMONY-5933) FutureTask.cancel() might not actaully cancel the task In-Reply-To: <932036475.1217954084433.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HARMONY-5933?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Tim Ellison closed HARMONY-5933. -------------------------------- Resolution: Invalid Please re-open if this is shown to be a problem in the Harmony code. > FutureTask.cancel() might not actaully cancel the task > ------------------------------------------------------ > > Key: HARMONY-5933 > URL: https://issues.apache.org/jira/browse/HARMONY-5933 > Project: Harmony > Issue Type: Bug > Components: Classlib > Affects Versions: 5.0M6 > Reporter: Jarek Gawor > > In some circumstances java.util.concurrent.FutureTask.cancel() might not actaully cancel the task. The problem is in innerCancel() method: > 1. boolean innerCancel(boolean mayInterruptIfRunning) { > 2. int s = getState(); > 3. if (ranOrCancelled(s) || !compareAndSetState(s, CANCELLED)) > 4. return false; > 5. > The issue is that the state (s) can change between line 2 and 3 and so compareAndSetState(s, CANCELLED) will return false and the cancel logic will not be performed (cancel() will return false but that task is not complete and it will continue to execute). This problem is more evident with periodic tasks where the state keep changing between 0 -> RUNNING, and RUNNING -> 0 (see innerRunAndReset()). > Looks like FutureTask implementation in Sun's JDK avoids this problem by adding a for (;;) loop around line 2 and 3: > for (;;) { > int s = getState(); > if (ranOrCancelled(s)) { > return false; > } > if (compareAndSetState(s, CANCELLED)) { > break; > } > } > -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.