You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Emmanuel Bourg (JIRA)" <ji...@apache.org> on 2007/06/01 10:50:15 UTC

[jira] Commented: (CONFIGURATION-277) AbstractConfiguration should handle UnsupportedOperationExceptions in Iterator.remove() gracefully

    [ https://issues.apache.org/jira/browse/CONFIGURATION-277?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12500624 ] 

Emmanuel Bourg commented on CONFIGURATION-277:
----------------------------------------------

I'm not sure this can be changed, if clearProperty is called in the loop a ConcurrentModificationException may be thrown. The keys to be removed could be collected in the loop and then removed outside the loop on the keys iterator.


> AbstractConfiguration should handle UnsupportedOperationExceptions in Iterator.remove() gracefully
> --------------------------------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-277
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-277
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 1.4
>            Reporter: Michael Rudolf
>
> 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

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org