commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting (JIRA)" <>
Subject [jira] Commented: (IO-159) FileCleaningTracker: ReferenceQueue uses raw type
Date Thu, 22 Jan 2009 01:35:59 GMT


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:

    Tracker tracker = null;
    try {
        // Wait for a tracker to remove.
        tracker = (Tracker) q.remove();
    } catch (Exception e) {
    if (tracker != null) {

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:

        tracker = q.remove().get();

> FileCleaningTracker: ReferenceQueue uses raw type
> -------------------------------------------------
>                 Key: IO-159
>                 URL:
>             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.

View raw message