[ https://issues.apache.org/jira/browse/LUCENE-4639?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13537383#comment-13537383 ]
Shai Erera commented on LUCENE-4639: ------------------------------------ Dawid, I've decided not to change the "magic formula". For two reasons: # That's not the reason I opened this issue - all I want is to be able to run the same test w/ same seed on Windows and not get Access is denied. And in light of all the recent comments, I think it's better if the rest of the logic stays as-is. # I think that the magic formula tries to reduce the chance for collision by using the higher bits of the integer (div by 64K is like >>16). Not sure how different it is for an int, as it's only 4 bytes, so after the division you're still left w/ the same range of values as if you did & 0xFFFF. Maybe the code originally pulled a long? Hmm ... but I think that won't matter either. Anyway, if we want to change any of this randomness / magic formulas, maybe we should just set counter statically to System.currentTimeMillis() or System.nanoTime() & 0xFFFF. But I'm too tired to think about this now. For now, I just want to allow rerunning tests on Windows. I'll attach a patch shortly. > 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, 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