You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Mike Drob (JIRA)" <ji...@apache.org> on 2015/11/17 18:55:11 UTC

[jira] [Commented] (SOLR-8304) SolrIndexWriter can throw NPE during finalize if create fails

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

Mike Drob commented on SOLR-8304:
---------------------------------

It appears that we won't be able to catch errors during construction to set a state variable, since from our perspective the object never exists. That means we need to null-check docWriter in the close, but would also need to null-check any new fields that we introduce in the future if we also use them in close. An alternative would be to explicitly set some kind of "finished initializing" field at the end of the constructor, and null-check that. It's more future proof, but also a bit more opaque - not sure what the better solution here is. Anybody have thoughts?

> SolrIndexWriter can throw NPE during finalize if create fails
> -------------------------------------------------------------
>
>                 Key: SOLR-8304
>                 URL: https://issues.apache.org/jira/browse/SOLR-8304
>             Project: Solr
>          Issue Type: Bug
>    Affects Versions: 4.10.3, 5.3
>            Reporter: Mike Drob
>             Fix For: Trunk
>
>
> When {{SolrIndexWriter.create()}} fails (likely to some IOException), then the finalizer can still be called on the partially constructed object ([ref|http://stackoverflow.com/questions/14483279/can-finalize-be-called-after-a-constructor-throws-an-exception]).
> This will lead to trying to close an index that is not fully initialized, and give us some not so desirable behaviour. From a 4.10.3 insance:
> {noformat}
> 2015-11-12 15:55:16,295 ERROR org.apache.solr.update.SolrIndexWriter: Error closing IndexWriter
> java.lang.NullPointerException
>         at org.apache.lucene.index.IndexWriter.doFlush(IndexWriter.java:3237)
>         at org.apache.lucene.index.IndexWriter.flush(IndexWriter.java:3210)
>         at org.apache.lucene.index.IndexWriter.shutdown(IndexWriter.java:907)
>         at org.apache.lucene.index.IndexWriter.close(IndexWriter.java:984)
>         at org.apache.lucene.index.IndexWriter.close(IndexWriter.java:954)
>         at org.apache.solr.update.SolrIndexWriter.close(SolrIndexWriter.java:129)
>         at org.apache.solr.update.SolrIndexWriter.finalize(SolrIndexWriter.java:182)
>         at java.lang.System$2.invokeFinalize(System.java:1270)
>         at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:98)
>         at java.lang.ref.Finalizer.access$100(Finalizer.java:34)
>         at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:210)
> {noformat}



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

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