[ https://issues.apache.org/jira/browse/GROOVY-8271?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-8271. ----------------------------- > Take/TakeRight methods on iterator needlessly calls hasNext for one too many > elements > ------------------------------------------------------------------------------------- > > Key: GROOVY-8271 > URL: https://issues.apache.org/jira/browse/GROOVY-8271 > Project: Groovy > Issue Type: Bug > Components: groovy-jdk > Affects Versions: 2.4.12 > Reporter: Marty Neal > Assignee: Paul King > Priority: Minor > Fix For: 2.4.13 > > > I expect the {{TakeIterator}} to only call the {{hasNext()}} method for the > delegate a maximum of {{N}} times where {{N}} is the number of elements to > take. If the iterator represents some expensive operations, or an > unexhausted infinite stream that has exactly {{N}} elements available, the > {{TakeIterator}} will block waiting for the {{Nth+1}} element only to return > {{N}} of them. > In short, change the {{TakeIterator}}'s {{hasNext}} function from > {{return delegate.hasNext() && num > 0;}} > to > {{return num > 0 && delegate.hasNext();}} -- This message was sent by Atlassian JIRA (v7.6.3#76005)