Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6969286

(fs) DirectoryStream may throw ConcurrentModificationException - rational not clear to developers

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 7
    • core-libs
    • x86
    • windows_2008

      A DESCRIPTION OF THE REQUEST :
      Really? New exceptions couldn't be introduced for this new API?

      Why is DirectoryStream overloading the semantics of ConcurrentModificationException and embedding "causes" that reflect the real exceptions?

        From JavaDoc:

      "Once a directory stream is closed, all further method invocations on the iterator throw ConcurrentModificationException with cause ClosedDirectoryStreamException."

      "The hasNext and next methods can encounter an I/O error when iterating over the directory in which case ConcurrentModificationException is thrown with cause IOException."

      "The iterator's remove method removes the directory entry for the last element returned by the iterator, as if by invoking the delete method. If an I/O error or security exception occurs then ConcurrentModificationException is thrown with the cause."

      None of these errors are a "ConcurrentModificationException". Why is it thrown with a cause of "ClosedDirectoryStreamException", for example, when throwing "ClosedDirectoryStreamException" directly makes more sense?

      This is the most ridiculous abuse of semantics I have seen in the JDK. I hope the rest of the JDK 7 API isn't this bad.



      JUSTIFICATION :
      Because we'll have to live with these stupid exceptions for the next 15 years. Everywhere we have to catch "ConcurrentModificationException" we will require additional code to dig out the "cause". Unbelievable.

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: