[Date Prev][Date Next] [Chronological] [Thread] [Top]

LDAPAttributeSet.iterator() returns iterator of com.novell.ldap.LDAPAttribute, not org.ietf.ldap.LDAPAttribute (ITS#2674)

Full_Name: Geoffrey Elgey
Version: JLDAP
OS: Linux
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (

The org.ietf.ldap.LDAPAttributeSet class includes the following code:

     * Returns an iterator over the elements of this set.
     * @see <a href="../../../../doc/com/novell/ldap/LDAPAttributeSet.html
    public Iterator iterator()
        return attrSet.iterator( );

This will return an iteration of com.novell.ldap.LDAPAttribute instances.
However, it should return an iteration of org.ietf.ldap.LDAPAttribute instances.

One solution is as follows:

  public Iterator iterator() {
    return new WrappedIterator(this.attrSet.iterator());
   * An iterator that creates org.ietf.ldap.LDAPAttribute instances
   * from an iterator of com.novell.ldap.LDAPAttribute instances.
  private static final class WrappedIterator implements Iterator { 
    // Iterator containing com.novell.ldap.LDAPAttribute instances.
    private final Iterator iterator;

    WrappedIterator(final Iterator iterator) { 
       this.iterator = iterator;

    public boolean hasNext() { 
      return this.iterator.hasNext();

    public Object next() { 
      com.novell.ldap.LDAPAttribute attr = 
        (com.novell.ldap.LDAPAttribute) this.iterator.next();
      return new LDAPAttribute(attr);