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

Vladimir Kuzmin commented on LUCENE-6770:
-----------------------------------------

Thanks, Uwe, I see obtainLock converts directory toRealPath anyway and adds 
then to concurent set LOCK_HELD. Do you mean tha NIO guarantees that call 
toRealPath will always return the same value even if link has changed? Is it 
documented behavior? Yes, we could add another method, like getLockDirectory 
and return toRealPath saved at ctor. My concern is that this all internal 
LOCK_HELD optimization looks useless and may even has some unpredictable 
behavior. I would always delegate it to system call. obtainLock tries to create 
lock file on every call, calls toRealPath, throws exception if failed to add to 
LOCK_HELD - it doesnt look like a solid optimization. In short, I would fix 
FSDirectory and remove static concurent set from NativeLockFactory at all. If 
obtainLock really needs optimization, we would need something like tryToObtain 
that returns true/false, check if Path is 'real', check LOCK_HELD before trying 
to create file. I can miss some historical reason though.

> FSDirectory ctor should use getAbsolutePath instead of getRealPath for 
> directory
> --------------------------------------------------------------------------------
>
>                 Key: LUCENE-6770
>                 URL: https://issues.apache.org/jira/browse/LUCENE-6770
>             Project: Lucene - Core
>          Issue Type: Improvement
>          Components: core/store
>    Affects Versions: 5.2.1
>         Environment: OS X, Linux
>            Reporter: Vladimir Kuzmin
>            Assignee: Uwe Schindler
>         Attachments: LUCENE-6770.patch
>
>
> After upgrade from 4.1 to 5.2.1 I found that one of our test failed. Appeared 
> the guilty was FSDirectory that converts given Path to Path.getRealPath. As 
> result the test will fail:
> Path p = Paths.get("/var/lucene_store");
> FSDirectory d = new FSDirectory(p);
> assertEquals(p.toString(), d.getDirectory().toString());
> It because /var/lucene_store is a symlink and 
> Path directory =path.getRealPath(); 
> resolves it to /private/var/lucene_store
> I think this is bad design decision because "direcrory" isn't just internal 
> state but is exposed in a public interface and "getDirectory()" is widely 
> used to initialize other components. 
> It should use paths.getAbsolutePath() instead.
> build and "ant test" were successful after fix.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to