Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4458862

ArrayIndexOutOfBoundException thrown decoding a javax.naming.Reference

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.3.0_01
    • core-libs



      Name: krC82822 Date: 05/15/2001


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      Problem first seen by a customer, trying to lookup a javax.naming.Referenceable
      object from an Active Directory Server(LDAP).

      The following exception occurs:

      java.lang.ArrayIndexOutOfBoundsException: 7 > 0
              at java.lang.Throwable.<init>(Throwable.java:96)
              at java.lang.Exception.<init>(Exception.java:44)
              at java.lang.RuntimeException.<init>(RuntimeException.java:49)
              at java.lang.IndexOutOfBoundsException.<init>
      (IndexOutOfBoundsException.java:46)
              at java.lang.ArrayIndexOutOfBoundsException.<init>
      (ArrayIndexOutOfBoundsException.java:55)
              at java.util.Vector.insertElementAt(Vector.java:557)
              at javax.naming.Reference.add(Reference.java:277)
              at com.sun.jndi.ldap.Obj.decodeReference(Obj.java:462)
              at com.sun.jndi.ldap.Obj.decodeObject(Obj.java:233)
              at com.sun.jndi.ldap.LdapCtx.c_lookup(LdapCtx.java:808)
              at com.sun.jndi.toolkit.ctx.ComponentContext.p_lookup
      (ComponentContext.java:526)
              at com.sun.jndi.toolkit.ctx.PartialCompositeContext.lookup
      (PartialCompositeContext.java:159)
              at com.sun.jndi.toolkit.ctx.PartialCompositeContext.lookup
      (PartialCompositeContext.java:148)
              at javax.naming.InitialContext.lookup(InitialContext.java:351)
              at BindTwice.main(BindTwice.java:34)

      Further analysis:

      The stored LDAP javaNamingReference entry has a javaReferenceAddress attribute
      that has 8 distinct values. These values are returned from the Directory Server
      in an order that is reverse of what might be expected(namely
      #7,#6,#5,#4,#3,#2,#1,#0). This is not incorrect behaviour on the part f the
      Directory Server. Section 4.1.8 of the LDAPv3 Spec states:

      "Each attribute value is distinct in the set (no duplicates). The order of
      attribute values within the vals set is undefined and implementation-dependent,
      and MUST NOT be relied upon. "

      Suspect problem is that com.sun.jndi.ldap.Obj and javax.naming.Reference code
      assume that attribute values are returned in the order they were inserte
      (#0,#1,#2,#3...). Under this assumption, the java.util.Vector method
      insertElementAt() is used. However, from the Vector.insertElementAt javadoc:

      "The index must be a value greater than or equal to 0 and less than or equal to
      the current size of the vector. (If the index is equal to the current size of
      the vector, the new element is appended to the Vector.)"
      (Review ID: 124414)
      ======================================================================

            rleesunw Rosanna Lee (Inactive)
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: