Commons IO
  1. Commons IO
  2. IO-230

DirectoryWalker needs to use generics to avoid compilation warnings

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.4
    • Fix Version/s: 2.0
    • Component/s: Utilities
    • Labels:

      Description

      When overriding methods such as handleFile, a generic Collection object is passed in argument. One is expected to add something to it, such as in this excerpt from DirectoryWalker's own javadoc:

        protected void handleFile(File file, int depth, Collection results) {
          [...]
          results.add(file);  // This lines triggers a warning.
        }
      

      This code triggers a warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Collection. I believe the right fix is to change DirectoryWalker to be parameterized by a type T so that the signature of handleFile (and other similar methods) can be changed to receive a Collection<T> in argument.

        Activity

        Benoit Sigoure created issue -
        Niall Pemberton made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.0 [ 12312961 ]
        Resolution Fixed [ 1 ]
        Henri Yandell made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Workflow jira [ 12500530 ] Default workflow, editable Closed status [ 12601906 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Benoit Sigoure
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development