Closed Bug 28005 Opened 25 years ago Closed 24 years ago

Exceptions thrown in connect and disconnect

Categories

(Directory :: LDAP Java SDK, defect, P3)

Other
Solaris
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: Thomas.Beyer, Assigned: miodrag)

Details

Under heavy load we get from time to time the following exceptions
(LDAP-SDK 4.0, Sun's JDK 1.2.2, Solaris 2.6 and Windows NT 4.0):

------------------------ on Windows NT --------------------------------------

java.util.NoSuchElementException: Vector Enumeration
        at java.util.Vector$1.nextElement(Vector.java, Compiled Code)
        at netscape.ldap.LDAPConnection.getNewThread(LDAPConnection.java, 
Compiled Code)
        at netscape.ldap.LDAPConnection.connect(LDAPConnection.java, Compiled 
Code)
        at netscape.ldap.LDAPConnection.connect(LDAPConnection.java, Compiled 
Code)
        at netscape.ldap.LDAPConnection.connect(LDAPConnection.java, Compiled 
Code)
        at LDAP.Bind(LDAP.java, Compiled Code)
        at thr.run(thr.java, Compiled Code)

java.lang.NullPointerException
        at netscape.ldap.LDAPConnection.deleteThreadConnEntry
(LDAPConnection.java, Compiled Code)
        at netscape.ldap.LDAPConnection.disconnect(LDAPConnection.java, 
Compiled Code)
        at LDAP.Unbind(LDAP.java, Compiled Code)
        at thr.run(thr.java, Compiled Code)

------------------------ on SUN -----------------------------------------------

java.util.NoSuchElementException: Vector Enumeration
        at java.lang.Throwable.fillInStackTrace(Native Method)
        at java.lang.Throwable.fillInStackTrace(Compiled Code)
        at java.lang.Throwable.<init>(Compiled Code)
        at java.lang.Exception.<init>(Exception.java:42)
        at java.lang.RuntimeException.<init>(RuntimeException.java:47)
        at java.util.NoSuchElementException.<init>
(NoSuchElementException.java:46)
        at java.util.Vector$1.nextElement(Compiled Code)
        at netscape.ldap.LDAPConnection.deleteThreadConnEntry(Compiled Code)
        at netscape.ldap.LDAPConnection.disconnect(LDAPConnection.java:1772)
        at LDAP.Unbind(Compiled Code)
        at thr.run(Compiled Code)

java.lang.NullPointerException
        at netscape.ldap.LDAPConnection.deleteThreadConnEntry
(LDAPConnection.java, Compiled Code)
        at netscape.ldap.LDAPConnection.disconnect(LDAPConnection.java, 
Compiled Code)
        at LDAP.Unbind(LDAP.java, Compiled Code)
        at thr.run(thr.java, Compiled Code)

-----------------------------------------------------------------------------

The exceptions can be easily reproduced with a program that creates
some (e.g. 16) threads and each threads run methods goes like this:

LDAPConnection 	ld = new LDAPConnection ();

for (int i = 1; i <= numRuns; i++) {

  try {
    ld.connect (host,port);
    ld.disconnect ();
  } catch (LDAPException e) { ...}

}

If we synchronize the connect and disconnect calls with the same
object:
  try {
    synchronized (obj) {
      ld.connect (host,port);
    }
    synchronized (obj) {
      ld.disconnect ();
    }
  } catch (LDAPException lde) { ...}

the problems don't occur. But the SDK is proposed to be threadsafe,
so the synchronization shouldn't be necessary.
Reassigned to Miodrag.
Assignee: mcs → miodrag
Status: NEW → ASSIGNED
The problem is caused by the lack of synchronization in deleteThreadConnEntry 
method. 

The fix has been cheked in 05-06-00.

Checking in ldapjdk/netscape/ldap/LDAPConnection.java;
/cvsroot/mozilla/directory/java-sdk/ldapjdk/netscape/ldap/LDAPConnection.java,v
 <--  LDAPConnection.java
new revision: 1.17; previous revision: 1.16
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.