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

Uwe Schindler commented on LUCENE-6542:
---------------------------------------

Hi,
this was officially documented on the issue converting to NIO.2, but I forget 
it to add to MIGRATE.txt!

For correct Java 7 implementation and lock factory correctly working after the 
change (needs fully resolved absolute path), we have to ensure the directory 
exists *before* the FSDirectory ctor returns, other wise race conditions occur! 
The makeDirectories() enforces this.

Please don't warp this with Files.exists() because this is not really atomic 
and not a good check, because in fact we need *write* access to the directory 
at a later stage, too - because we call fsync on the directory itsself to 
ensure commits are written into the directory file itsself.

Please don't add any crazy semantics to TestSecurityManager: The reason why it 
does not work for you with this hack is because of the internal backwards 
compatibility in SecurityManager to handle pre-Java 1.2 (or like that), where 
SecurityManager did not know about permissions. At that time it used to call 
checkWrite(), which now delegates in strange ways - they would need 
VirtualMethod class from Lucene to handle this correctly :-)

I don't see this as a bug: Lucene "owns" the directory, so it must be able to 
create/delete/fsync/whatever it. If the directory is on a read-only FS and you 
just open DirectoryReader, its perfectly fine if the directory exists (no OS 
error). It is just FilePermission that complains.

> FSDirectory throws AccessControlException unless you grant write access to 
> the index
> ------------------------------------------------------------------------------------
>
>                 Key: LUCENE-6542
>                 URL: https://issues.apache.org/jira/browse/LUCENE-6542
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: core/store
>    Affects Versions: 5.1
>            Reporter: Trejkaz
>              Labels: regression
>         Attachments: LUCENE-6542.patch, patch.txt
>
>
> Hit this during my attempted upgrade to Lucene 5.1.0. (Yeah, I know 5.2.0 is 
> out, and we'll be using that in production anyway, but the merge takes time.)
> Various tests of ours test Directory stuff against methods which the security 
> policy won't allow tests to write to. Changes in FSDirectory mean that it now 
> demands write access to the directory. 4.10.4 permitted read-only access.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to