Github user tkruse commented on a diff in the pull request:
https://github.com/apache/groovy/pull/360#discussion_r69132663
--- Diff: src/main/groovy/lang/ObjectRange.java ---
@@ -408,107 +401,86 @@ public void step(int step, Closure closure) {
*/
@Override
public Iterator iterator() {
- // non thread-safe iterator
- final Iterator innerIterator = new StepIterator(this, 1);
- final Iterator safeIterator = new Iterator() {
+ return new Iterator() {
+ private final Iterator delegate = new
LazySteppingIterator(ObjectRange.this, 1);
+
@Override
public synchronized boolean hasNext() {
- return innerIterator.hasNext();
+ return delegate.hasNext();
}
@Override
public synchronized Object next() {
- return innerIterator.next();
+ return delegate.next();
}
@Override
- public void remove() {
- innerIterator.remove();
+ public synchronized void remove() {
--- End diff --
no, don't synchronize it. Call innerIterator.remove(); like before. I know
innerIterator.remove() also always throws, but still it's better to have just
one location that throws.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---