directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kiran Ayyagari (JIRA)" <>
Subject [jira] [Commented] (DIRSHARED-124) SearchCursorImpl breaks java.lang.Iterable
Date Wed, 04 May 2011 05:26:03 GMT


Kiran Ayyagari commented on DIRSHARED-124:

The issue is in the method, which is calling get() before calling next()
on the underlying cursor.
However i think this can be fixed by changing the CursorIterator.hasNext() to call underlying
cursor's next() method and return it's value rather than maintaining a
available flag locally and making to just return the value returned
from underlying cursor's get().

> SearchCursorImpl breaks java.lang.Iterable
> ------------------------------------------
>                 Key: DIRSHARED-124
>                 URL:
>             Project: Directory Shared
>          Issue Type: Bug
>    Affects Versions: 1.0.0-M3
>            Reporter: Gerald Turner
>            Priority: Minor
> Code like:
>   SearchCursor search =;
>   for (Response response : search) { ... }
> Does not work (no elements iterated), even though SearchCursor is advertised as being
> The problem begins with the CursorIterator constructor:
>     public CursorIterator( Cursor<E> cursor )
>     {
>         this.cursor = cursor;
>         this.available = cursor.available();
>     }
> The available field will be set to false for SearchCursorImpl, just as the javadoc in
Cursor implies "Determines whether or not a call to get() will succeed." - since next() must
be called first.
> Initially I thought about patching the CursorIterator to call next() instead of available(),
however next throws an exception and it is impractical to handle an exception in the iterator

This message is automatically generated by JIRA.
For more information on JIRA, see:

View raw message