lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LUCENE-4183) Simplify CompoundFileDirectory opening in 4.x
Date Mon, 02 Jul 2012 10:38:22 GMT

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

Uwe Schindler commented on LUCENE-4183:
---------------------------------------

bq. How was it broken? Shouldnt TestIndexWriterExceptions fail?

It is not completely broken, but the code does not always set success=true when it succeeds.
This causes that the wrong Exception is throws/rethrown. The problem is the stacktrace: if
close() throws exception in the finally block, it is visible only if success=true otherwise
the system supresses it.

Unfortunately, we now have too many patterns for correct try-with-resources like Exception
handling, lots of cases suppress exceptions in Java 7 systems completely, others throw the
wrongf exception, so user does no longer see the root cause, just because close() itsself
throws ex and overrides the cause (happens often with buffered streams or network connections).

We should deprecate all unneeded methods in IOUtils and for future development *only* use
the official pattern using:

{code:java}
IOException priorE=null;
Closeable a = null, b = null,...;
try {
  a = new Closeable()...
  ...
} catch (IOExeception ioe) {
  priorE = ioe;
} finally {
  // this will handle rethrowing the right exception, with supressed exceptions atached as
supression cause, and handle null if no error
  closeWhileHandlingException(priorE, a, b,...);
}
{code}

Example code see my work on Kumoroji!

The code using the boolean-only success supresses too much information. I dont want to fix
existing code unless behaving incorrectly.

*For Lucene 5.0 I propose to go to Java 7 as minimum requirement* and use the syntactic sugar
that always does-the-right thing:

{code:java}
try (Closeable a = new Closeable(), b =...) {
  ...
}
{code}
                
> Simplify CompoundFileDirectory opening in 4.x
> ---------------------------------------------
>
>                 Key: LUCENE-4183
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4183
>             Project: Lucene - Java
>          Issue Type: Improvement
>    Affects Versions: 4.0
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 4.0
>
>         Attachments: LUCENE-4183.patch
>
>
> The compiler bug in JDK 8EA let me look at the code again. I opened bug report with simple
test case at Oracle, but the code on our side is still too complicated to understand.
> The attached path for 4.x removes the nested try-finaly block and simpliefies success=true
handling (which was in fact broken). It uses a more try-with-resources like approach with
only one finally block.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


Mime
View raw message