Uploaded image for project: 'Commons Configuration'
  1. Commons Configuration
  2. CONFIGURATION-277

AbstractConfiguration should handle UnsupportedOperationExceptions in Iterator.remove() gracefully

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.4
    • Fix Version/s: 1.5
    • Component/s: None
    • Labels:
      None

      Description

      Hi,

      In AbstractConfiguration method clear() on line 533 (see code below) a possible UnsupportedOperationException is not caught resulting in the malfunctioning of the whole method. However, the documentation of the getKeys() method itself warns about relying on the remove() method of interface Iterator. The clear() method should not propagate that exception, it should catch it and try the clearProperty(String) approach if the remove() method is not supported.

      Iterator it = getKeys();
      while (it.hasNext())
      {
      String key = (String) it.next();
      it.remove(); <------- EVIL!

      if (containsKey(key))

      { // workaround for Iterators that do not remove the property on calling remove() clearProperty(key); }

      Best regards,
      Michael

        Attachments

          Activity

            People

            • Assignee:
              oheger Oliver Heger
              Reporter:
              javaprog Michael Rudolf
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: