accumulo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christopher Tubbs (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (ACCUMULO-4013) Clean up new warnings
Date Wed, 30 Sep 2015 15:38:04 GMT

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

Christopher Tubbs commented on ACCUMULO-4013:
---------------------------------------------

Apparently the warning was being generated by a few things.

One warning was because of an identified resource leak when we constructed a reader, and then
instead of returning the whole {{reader}}, we just returned {{reader.getIndex()}}. Part of
this is just bad API design on the {{RFile}} and related classes, which makes it difficult
to use correctly while properly managing the object's lifecycle. I think we inherited most
of that design from {{TFile}}. At some point, we should probably clean that API up. I fixed
this with a separate private utility method to return the reader directly. That suffices as
a hint that the caller will manage the object's lifecycle, and a warning should not be generated
if it's not closed before the end of the method.

Another warning was related to clobbering one reference to an {{AutoCloseable}} with another
before closing the first one. Eclipse (and perhaps other compilers) warned about this, because
it failed to detect that we already had another reference to the first {{AutoCloseable}}.
I fixed this by moving the assignment to an {{else}} clause, rather than always assigning
it and then clobbering it conditionally.

A third warning was simply because an {{IllegalArgumentException}} could occur without closing
the reader. I put the reader into a try-with-resources block and all was fixed.

> Clean up new warnings
> ---------------------
>
>                 Key: ACCUMULO-4013
>                 URL: https://issues.apache.org/jira/browse/ACCUMULO-4013
>             Project: Accumulo
>          Issue Type: Task
>            Reporter: Christopher Tubbs
>            Assignee: Christopher Tubbs
>            Priority: Trivial
>             Fix For: 1.6.5, 1.7.1, 1.8.0
>
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> Looks like several of our branches have had some warnings introduced recently.
> I'm going to go through and clean these up if possible. Mostly, they're trivial warnings
about unclosed resources (or potentially unclosed resources), and unused code.
> Some are only showing up in more recent Java compilers or IDEs. Others were introduced
with code changes.



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

Mime
View raw message