[
https://issues.apache.org/jira/browse/LUCENE-6770?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14737116#comment-14737116
]
Vladimir Kuzmin commented on LUCENE-6770:
-----------------------------------------
Uwe, it makes it clear. Can you also clarify the last thing. I see the code at
NativeFSLockFactory.java:
87 protected Lock obtainFSLock(FSDirectory dir, String lockName) throws
IOException {
88 Path lockDir = dir.getDirectory();
89
90 // Ensure that lockDir exists and is a directory.
91 // note: this will fail if lockDir is a symlink
92 Files.createDirectories(lockDir);
93
94 Path lockFile = lockDir.resolve(lockName);
95
96 try {
97 Files.createFile(lockFile);
98 } catch (IOException ignore) {
99 // we must create the file to have a truly canonical path.
100 // if it's already created, we don't care. if it cant be created,
it will fail below.
101 }
102
103 // fails if the lock file does not exist
104 final Path realPath = lockFile.toRealPath();
So, it calls toRealPath also. Does it mean that it relies on that after
FSDirectory called
directory = path.toRealPath();
second call
directory.toRealPath()
doesn't resolve it but returns some internal state? I wasn't able to find this
at documentation.
> 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: [email protected]
For additional commands, e-mail: [email protected]