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

Michael McCandless commented on LUCENE-4649:
--------------------------------------------

So e.g. we would fix IW methods to throw the [checked] InterruptedException, or 
would they also wrap it under an IOException?  Why should should FSDir.sync 
pretend this was an IOException not an interrupt?

The problem here is using Thread.interrupt is dangerous if you use MMapDir or 
NIOFSDir, ie the interrupt may close file handles and make the IR unusable (and 
eg lose a flushed segment if it's IW).  So advertising that tons of methods now 
throw the checked InterruptedException might make users think these methods are 
in fact safely interruptible when they are not ...
                
> kill ThreadInterruptedException
> -------------------------------
>
>                 Key: LUCENE-4649
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4649
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Robert Muir
>
> the way we currently do this is bogus.
> For example in FSDirectory's fsync, i think we should instead:
> {noformat}
> } catch (InterruptedException ie) {
> - throw new ThreadInterruptedException(ie);
> + Thread.currentThread().interrupt(); // restore status
> + IOException e = new java.io.InterruptedIOException("fsync() interrupted");
> + e.initCause(ie);
> + throw e;
> {noformat}
> and crazy code in IndexWriter etc that catches ThreadInterruptedExc just to 
> restore status should be removed. 
> Instead the guy doing the catch (InterruptedException) should do the right 
> thing.

--
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

Reply via email to