[ https://issues.apache.org/jira/browse/VFS-658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16427537#comment-16427537 ]
Gary Gregory commented on VFS-658: ---------------------------------- Thank you for your report [~Bingo]: Can you provide a PR with a unit test on GitHub? https://github.com/apache/commons-vfs It is best if the unit test fails without the main code changes. Gary > 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 > Priority: Major > > 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)