Last Comment Bug 28005 - Exceptions thrown in connect and disconnect
: Exceptions thrown in connect and disconnect
Status: RESOLVED FIXED
:
Product: Directory
Classification: Components
Component: LDAP Java SDK (show other bugs)
: other
: Other Solaris
: P3 normal (vote)
: ---
Assigned To: miodrag
:
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2000-02-16 09:10 PST by Thomas.Beyer
Modified: 2000-05-06 13:05 PDT (History)
0 users
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments

Description Thomas.Beyer 2000-02-16 09:10:41 PST
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.
Comment 1 Mark Smith (:mcs) 2000-02-16 10:25:32 PST
Reassigned to Miodrag.
Comment 2 miodrag 2000-05-06 13:05:54 PDT
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

Note You need to log in before you can comment on or make changes to this bug.