Return-Path: Delivered-To: apmail-lucene-dev-archive@www.apache.org Received: (qmail 79929 invoked from network); 1 May 2010 07:52:19 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 1 May 2010 07:52:19 -0000 Received: (qmail 30404 invoked by uid 500); 1 May 2010 07:52:18 -0000 Delivered-To: apmail-lucene-dev-archive@lucene.apache.org Received: (qmail 30248 invoked by uid 500); 1 May 2010 07:52:18 -0000 Mailing-List: contact dev-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list dev@lucene.apache.org Received: (qmail 30241 invoked by uid 99); 1 May 2010 07:52:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 May 2010 07:52:18 +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.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 May 2010 07:52:15 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o417psoq021069 for ; Sat, 1 May 2010 07:51:54 GMT Message-ID: <24310265.48821272700314007.JavaMail.jira@thor> Date: Sat, 1 May 2010 03:51:54 -0400 (EDT) From: "Uwe Schindler (JIRA)" To: dev@lucene.apache.org Subject: [jira] Issue Comment Edited: (LUCENE-2421) Hardening of NativeFSLock In-Reply-To: <24749183.5191272547014166.JavaMail.jira@thor> 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/LUCENE-2421?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12862994#action_12862994 ] Uwe Schindler edited comment on LUCENE-2421 at 5/1/10 3:51 AM: --------------------------------------------------------------- bq. The file created included the @ character, which is valid on Windows (and also verified on Linux). But I'm still not sure about using it, because if a system returns a character that is not a valid file character, we may not get the same file name we think ... so maybe if we still want to use it, we should move it to the end of the string, so that the name includes the random number for sure ... what do you think? I suggested on IRC to take the output of getName() and do a regexp replace and replace all non ACSII-digit chars: {code} ManagementFactory.getRuntimeMXBean().getName().replaceAll("[^a..zA..Z0..9]+","") {code} Or alternatively simply use the hashCode of that String (but that is less unique). was (Author: thetaphi): bq. The file created included the @ character, which is valid on Windows (and also verified on Linux). But I'm still not sure about using it, because if a system returns a character that is not a valid file character, we may not get the same file name we think ... so maybe if we still want to use it, we should move it to the end of the string, so that the name includes the random number for sure ... what do you think? I suggested on IRC to take the output of getName() and do a regexp replace and replace all non ACSII-digit chars: {code} ManagementFactory.getRuntimeMXBean().getName().replaceAll("[^a..zA..Z0..9]","") {code} Or alternatively simply use the hashCode of that String (but that is less unique). > Hardening of NativeFSLock > ------------------------- > > Key: LUCENE-2421 > URL: https://issues.apache.org/jira/browse/LUCENE-2421 > Project: Lucene - Java > Issue Type: Improvement > Components: Index > Reporter: Shai Erera > Assignee: Shai Erera > Fix For: 3.1 > > Attachments: LUCENE-2421.patch, LUCENE-2421.patch > > > NativeFSLock create a test lock file which its name might collide w/ another JVM that is running. Very unlikely, but still it happened a couple of times already, since the tests were parallelized. This may result in a false exception thrown from release(), when the lock file's delete() is called and returns false, because the file does not exist (deleted by another JVM already). In addition, release() should give a second attempt to delete() if it fails, since the file may be held temporarily by another process (like AntiVirus) before it fails. The proposed changes are: > 1) Use ManagementFactory.getRuntimeMXBean().getName() as part of the test lock name (should include the process Id) > 2) In release(), if delete() fails, check if the file indeed exists. If it is, let's attempt a re-delete() few ms later. > 3) If (3) still fails, throw an exception. Alternatively, we can attempt a deleteOnExit. > I'll post a patch later today. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org For additional commands, e-mail: dev-help@lucene.apache.org