lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laimonas Simutis <lai...@gmail.com>
Subject Unauthorized Access Exceptions in tests
Date Mon, 05 Jan 2015 13:56:09 GMT
Tests occassionally fail with Unauthorized access exception with stack
trace pointing here:

https://github.com/apache/lucenenet/blob/master/src/Lucene.Net.Core/Util/IOUtils.cs#L444

To understand the full issue, you can see how it is being called from here:

https://github.com/apache/lucenenet/blob/master/src/Lucene.Net.Core/Store/FSDirectory.cs#L387

Note how it first fsyncs the files and then if there were any that were
fsynced, it fsyncs a directory containing the files. Directory part is the
one that is causing the problems.

The issue is that fsync implementation in the IOUtils is using FileStream
class to flush both files and directories. Doing so for directories throws
Access Denied exception, always. FileStream class cannot be used to "open"
directories.


Trying to think how to fix this. The simplest one is to catch Access Denied
thrown and ignore it. You can see how the existing implementation does this
for IOException catch branch. if dir is true, the IOException is ignored
and method passes. That would be the simplest thing to do to get the tests
passing. Heck, even ignore the whole fsync if it is for directory.

I do think the complete approach would involve falling back to native
functions (CreateFile for Windows to get directory's handle:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspx
or equivalent in non Windows) and then call FlushFileBuffers or equivalent
in non-Windows. It is kind of what is present in FileSupport class (
https://github.com/apache/lucenenet/blob/master/src/Lucene.Net.Core/Support/FileSupport.cs)
but not fully implemented. It seems like IOUtils tried to use FileSupport
Sync implementation but it was commented out. Does anybody know anything
about that? Why it was commented out, etc?

Looking for advice here on how to proceed. There is a good number of tests
failing this way so it would be a nice issue to take care off. Perhaps go
with the simple route and mark the full implementation for TODO?


Laimonas

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message