lucene-solr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hoss Man (JIRA)" <j...@apache.org>
Subject [jira] Commented: (SOLR-914) Presence of finalize() in the codebase
Date Sat, 15 Aug 2009 07:37:14 GMT

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

Hoss Man commented on SOLR-914:
-------------------------------

I don't understand objections to the idea that finalize should close if (and only it) the
resource hasn't already been closed ... people shouldn't relying on it, but having code that
aids in the prevention of resource leaks doesn't seem like abad thing to me.

the only things i would change about this patch...
   * make the logging done by the finalizer methods more serious (error or maybe even fatal)
and make them convey *why* it's an error ("...was not closed prior to finalizing")
   * SolrIndexWriter.finalize() still calls super.close() (only this.close() should ever call
super.close())


> Presence of finalize() in the codebase 
> ---------------------------------------
>
>                 Key: SOLR-914
>                 URL: https://issues.apache.org/jira/browse/SOLR-914
>             Project: Solr
>          Issue Type: Improvement
>          Components: clients - java
>    Affects Versions: 1.3
>         Environment: Tomcat 6, JRE 6
>            Reporter: Kay Kay
>            Priority: Minor
>             Fix For: 1.4
>
>         Attachments: SOLR-914.patch
>
>   Original Estimate: 480h
>  Remaining Estimate: 480h
>
> There seems to be a number of classes - that implement finalize() method.  Given that
it is perfectly ok for a Java VM to not to call it - may be - there has to some other way
 { try .. finally - when they are created to destroy them } to destroy them and the presence
of finalize() method , ( depending on implementation ) might not serve what we want and in
some cases can end up delaying the gc process, depending on the algorithms. 
> $ find . -name *.java | xargs grep finalize
> ./contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/JdbcDataSource.java:
 protected void finalize() {
> ./src/java/org/apache/solr/update/SolrIndexWriter.java:  protected void finalize() {
> ./src/java/org/apache/solr/core/CoreContainer.java:  protected void finalize() {
> ./src/java/org/apache/solr/core/SolrCore.java:  protected void finalize() {
> ./src/common/org/apache/solr/common/util/ConcurrentLRUCache.java:  protected void finalize()
throws Throwable {
> May be we need to revisit these occurences from a design perspective to see if they are
necessary / if there is an alternate way of managing guaranteed destruction of resources.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message