You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "binchen (JIRA)" <ji...@apache.org> on 2018/04/04 02:33:00 UTC

[jira] [Created] (VFS-658) org.apache.commons.vfs2.util.CombinedResources.getKeys() fail

binchen created VFS-658:
---------------------------

             Summary: org.apache.commons.vfs2.util.CombinedResources.getKeys() fail
                 Key: VFS-658
                 URL: https://issues.apache.org/jira/browse/VFS-658
             Project: Commons VFS
          Issue Type: Bug
    Affects Versions: 2.2
            Reporter: binchen


Invoke CombinedResource.getKeys() could lead to a dead cycle. source code :

@Override
 public Enumeration<String> getKeys() {
 if (!inited) {
 init();
 }
 *return new Enumeration<String>() {*
 *@Override*
 *public boolean hasMoreElements() {*
 *return properties.keys().hasMoreElements();*
 *}*

*@Override*
 *public String nextElement() {*
 *// We know that our properties will only ever contain Strings*
 *return (String) properties.keys().nextElement();*
 *}*

*}*;
 }

The bold code above has bugs, the right code may be like below:

_return new Enumeration<String>() {_
 _Enumeration<Object> proEnums = CombinedResources.this.properties.keys();_

_@Override_
 _public boolean hasMoreElements() {_
 _return this.proEnums.hasMoreElements();_
 _}_

_@Override_
 _public String nextElement() {_
 _// We know that our properties will only ever contain Strings_
 _return (String) this.proEnums.nextElement();_
 _}_
 _};_

 

 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)