[
https://issues.apache.org/jira/browse/IO-159?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12666030#action_12666030
]
Jukka Zitting commented on IO-159:
----------------------------------
I looked at this briefly, and it seems like parameterizing the type actually
uncovers an error in the code. The nested Reaper class contains the following
code:
{code}
Tracker tracker = null;
try {
// Wait for a tracker to remove.
tracker = (Tracker) q.remove();
} catch (Exception e) {
continue;
}
if (tracker != null) {
tracker.delete();
tracker.clear();
trackers.remove(tracker);
}
{code}
The problem is that since q is a ReferenceQueue, the q.remove() call returns a
Reference instance and the cast will throw a ClassCastException which in turn
prevents the tracker from being properly cleared. I don't know the
FileCleaningTracker class well enough to know if this is a problem in practice,
but the above code certainly doesn't do what it was written to do.
With parametrized types we can get rid of the broken cast, and the troublesome
call becomes:
{code}
tracker = q.remove().get();
{code}
> FileCleaningTracker: ReferenceQueue uses raw type
> -------------------------------------------------
>
> Key: IO-159
> URL: https://issues.apache.org/jira/browse/IO-159
> Project: Commons IO
> Issue Type: Improvement
> Affects Versions: 2.0
> Reporter: Paul Benedict
> Priority: Minor
> Fix For: 2.0
>
>
> The field is:
> ReferenceQueue /* Tracker */ q = new ReferenceQueue();
> But that inline comment needs to become the parameterized type. Is it of type
> <?> ?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.