Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 74585 invoked from network); 16 Sep 2008 09:27:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Sep 2008 09:27:15 -0000 Received: (qmail 38965 invoked by uid 500); 16 Sep 2008 09:27:01 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 38919 invoked by uid 500); 16 Sep 2008 09:27:01 -0000 Mailing-List: contact dev-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 dev@harmony.apache.org Received: (qmail 38841 invoked by uid 99); 16 Sep 2008 09:27:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Sep 2008 02:27:01 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of t.p.ellison@gmail.com designates 74.125.78.148 as permitted sender) Received: from [74.125.78.148] (HELO ey-out-1920.google.com) (74.125.78.148) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Sep 2008 09:26:01 +0000 Received: by ey-out-1920.google.com with SMTP id 4so1123055eyg.24 for ; Tue, 16 Sep 2008 02:26:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :x-enigmail-version:content-type:content-transfer-encoding; bh=MQvXufIU+skPa5dosskpxhTdxtZt/LAPLi7JuCSdTPw=; b=jAZznQJR3Z9ZRe0KokH861EKa4RG2TxWLAWhZA6ltg/1Z4fvFIsCfsS/D0zc/QdhML GEzo2pBUuV7sOyp3ibu5LZdYF8luJ18HNZS0/0NNgbhqfCIEjCfdgbeKhQgC6IwckRyz o8D68NFFHD77J7EkmSuEX2l4mfbhCMQp/u50o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; b=hBLXM1Camv0aDu/6U8LaCzoucumz34zB6LHQ+CdoqSHLawLqwvw3ZmCyybDH2QCGB3 sCXqW01Pad5SBYN5yvuRqb1T6TEBx3A03xejR1aGQMeaQDXrjIBvzv9rR5ACVQxZmbLe IO4c6+5SgTVENrqPTIF5FWHX6Iomg0OKo57kg= Received: by 10.210.48.14 with SMTP id v14mr1010007ebv.82.1221557192949; Tue, 16 Sep 2008 02:26:32 -0700 (PDT) Received: from ?9.180.167.38? ( [195.212.29.67]) by mx.google.com with ESMTPS id g9sm214075gvc.0.2008.09.16.02.26.31 (version=SSLv3 cipher=RC4-MD5); Tue, 16 Sep 2008 02:26:31 -0700 (PDT) Message-ID: <48CF7C33.2020103@gmail.com> Date: Tue, 16 Sep 2008 10:28:19 +0100 From: Tim Ellison User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 To: dev@harmony.apache.org Subject: Re: [jira] Created: (HARMONY-5979) [classlib][luni] - File.deleteOnExit has different behaviours with RI References: <1710486863.1221105524325.JavaMail.jira@brutus> <48C8D5A3.8010806@gmail.com> <48C8E6C8.1000506@gmail.com> <48C91A10.9010002@gmail.com> <48C9D001.3000303@gmail.com> <48CF3C1E.8070207@gmail.com> In-Reply-To: <48CF3C1E.8070207@gmail.com> X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Regis wrote: > I double check the spec, it(deleted in the reverse order) is mentioned > in Java6, not Java5. > So we should only fix it on Java6 branch? No, I think the spec was clarified to describe the behavior that already existed in Java 5. I suggest you fix it in there. Regards, Tim > Jim Yu wrote: >> Hi Regis, >> IMO, RI's behavior is reasonable according to the spec which says >> "Files (or >> directories) are deleted in the reverse order that they are >> registered." So >> it is correct for RI to execute deleteOnExit() methods in the reverse >> order that you invoked in the test case. >> 2008/9/12 Regis >> >>> Actually Harmony delete files by the order of lenght of file path, >>> the file >>> with >>> longest path would be deleted first (not the order added to the >>> list). So >>> Harmony >>> can always successfully delete all marked files. The code is from >>> DeleteOnExit.java: >>> >>> public static void deleteOnExit() { >>> java.util.Collections.sort(deleteList, >>> new java.util.Comparator() { >>> public int compare(String s1, String s2) { >>> return s2.length() - s1.length(); >>> } >>> }); >>> for (int i = 0; i < deleteList.size(); i++) { >>> String name = deleteList.elementAt(i); >>> new File(name).delete(); >>> } >>> } >>> >>> I think it's smarter than RI. >>> >>> >>> Tim Ellison wrote: >>> >>>> Regis wrote: >>>> >>>>> The behavior of RI may leave some files marked as deleteOnExit >>>>> after vm >>>>> exit, so >>>>> it's confused why marked files wasn't deleted after vm exit, and it >>>>> doesn't match the >>>>> semantic of this method. Maybe it's RI's bug? >>>>> >>>> In general you can't tell what order will succeed in deleting all the >>>> files because you can't accurately determine the file system >>>> dependencies between them. >>>> >>>> Based on your test program, Harmony attempts the deletion in the order >>>> the files were added to the list, and the RI attempts them in the >>>> reverse order. I was just suggesting we modify Harmony to also do >>>> reverse order so any application that assumes this will continue to >>>> work. >>>> >>>> I agree it is a compatibility rather than spec' compliance issue >>>> though. >>>> >>>> Regards, >>>> Tim >>>> >>>> Tim Ellison wrote: >>>>>> I suggest Harmony changes to match the behavior of the RI in this >>>>>> case. >>>>>> >>>>>> It will avoid unnecessary incompatibilities and seems logical for >>>>>> programs that create dir and mark for deleteOnExit, then create files >>>>>> and mark for deleteOnExit etc. as they go. >>>>>> >>>>>> Regards, >>>>>> Tim >>>>>> >>>>>> Regis Xu (JIRA) wrote: >>>>>> >>>>>>> [classlib][luni] - File.deleteOnExit has different behaviours >>>>>>> with RI >>>>>>> --------------------------------------------------------------------- >>>>>>> >>>>>>> >>>>>>> >>>>>>> Key: HARMONY-5979 URL: >>>>>>> https://issues.apache.org/jira/browse/HARMONY-5979 Project: Harmony >>>>>>> Issue Type: Bug Components: Classlib Affects Versions: 5.0M7 >>>>>>> Reporter: Regis Xu Fix For: 5.0M8 >>>>>>> >>>>>>> >>>>>>> consider the following test: >>>>>>> >>>>>>> File f1 = new File("d1"); f1.mkdirs(); File f2 = new File("d1/d2"); >>>>>>> f2.mkdirs(); File f3 = new File("d1/d2/f1"); >>>>>>> >>>>>>> f3.createNewFile(); >>>>>>> >>>>>>> f3.deleteOnExit(); f2.deleteOnExit(); f1.deleteOnExit(); >>>>>>> >>>>>>> RI leaves d1 and d2, while Harmony deletes all of the three >>>>>>> files. If >>>>>>> we change the order of invoke deleteOnExit to f2.deleteOnExit(); >>>>>>> f3.deleteOnExit(); f1.deleteOnExit(); RI leaves d1, Harmony also >>>>>>> detete all the three files. It seems RI delete files in the reverse >>>>>>> order of invoking deleteOnExit. And spec doesn't mention which order >>>>>>> should be used, is it a non-bug difference, or we should fix it >>>>>>> to be >>>>>>> compatible with RI? >>>>>>> >>>>>>> >>>>>>> >> >> >