[ 
https://issues.apache.org/jira/browse/LUCENE-4639?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13536941#comment-13536941
 ] 

Shai Erera commented on LUCENE-4639:
------------------------------------

bq. mkdir doesn't declare any IOExceptions so I don't think it applies. Try it

I did try my test with that patch and it passes (if ran twice w/ same seed). I 
guess the problem w/ Windows is that it adheres to the specifics, as written. 
If a "file" exists, returns false. But if a directory exists, it throws an 
exception. mkdir() doesn't trip on it.

I found that ManagementFactory.getRuntimeMXBean().getName() can suggest the 
PID, but I guess that's what you mean by a "hint". I read on one thread that 
the runner should report the PID of a hang thread or something ... well 
definitely the words "runner" and "report PID" were mentioned in the same 
context. That's why I thought it has access to this info, maybe w/ some tricks 
from platform.jar ...

Regarding the magic noise, we still need the first part to get a short file 
name (convenience) and positive (to be on the safe side - don't want to create 
files w/ '-' in their name). The noise I gather you refer to 0x2710? It's 10000 
in decimal (couldn't someone just write that !?), but I still can't figure out 
why it is added to whatever the result of nextInt/64K ... I'll remove it.

Should I upload a newer patch, or are you ok with committing it (+ the removal 
of magic)?
                
> Improving _TestUtil.getTempDir
> ------------------------------
>
>                 Key: LUCENE-4639
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4639
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Shai Erera
>            Assignee: Shai Erera
>            Priority: Minor
>         Attachments: LUCENE-4639.patch, LUCENE-4639.patch
>
>
> Spinoff from here: 
> http://lucene.472066.n3.nabble.com/TestUtil-getTempFile-may-fail-on-quot-Access-Denied-quot-td4028048.html.
> _TestUtil.getTempDir uses createTempFile and then deletes the file. While 
> this usually works, if someone runs tests by multiple JVMs and does not 
> ensure each JVM gets an isolated temp.dir to work in, that my result in two 
> JVMs sharing the same directory.
> Also, on Windows, if you call getTempDir on an existing directory, you get an 
> "Access is denied" exception.
> Dawid proposed a simple solution to just call mkdirs() continuously until 
> success. I'd like to try that.
> Also, I think that genTempFile could use some house cleaning, e.g.:
> * tempFileLocker can be just an Object instance? Why do we need a class?
> * If we initialize counter and counterBase in a static clause, we can avoid 
> checking if counter==0 as well as passing Random to genTempFile (that will 
> remove any suspicion that it does anything randomly)
> ** Also, instead of synchronizing on tempFileLocker, can we just use 
> AtomicInteger for the counter?
> I'll modify getTempDir first. It documents "does not create the directory", I 
> want to make sure no test fails due that.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to