Closed Bug 232298 Opened 21 years ago Closed 21 years ago

Schema retrieval crashes with ClassCastException connection to openldap 2.1.22

Categories

(Directory :: LDAP Java SDK, defect)

x86
Linux
defect
Not set
critical

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: ingo.schaefer, Assigned: erhyuan)

Details

Attachments

(1 file, 1 obsolete file)

User-Agent: Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225 While retrieving the Schema from the LDAP Server, I got this message: java.lang.ClassCastException at netscape.ldap.LDAPMatchingRuleSchema.<init>(LDAPMatchingRuleSchema.java:223) at netscape.ldap.LDAPSchema.initialize(LDAPSchema.java:701) at netscape.ldap.LDAPSchema.<init>(LDAPSchema.java:190) at <my function> Doing the query to openldap 2.1.4 works without any problem. I investigated, that the older version of openldap does not support MatchingRuleUse, so this part of the code was never reached. I think, the error occours only, if the rule is used by exactly one attribute. The attribute entry in the Hashtable is in this case of type String and not a Vector. Reproducible: Always Steps to Reproduce: 1. Install openldap 2.1.22 2. ld = new LDAPConnection(); 3. ld.connect(3,LDAP_SERVER,389,LDAP_BINDDN,LDAP_BINDPWD); 4. ldapSchema = new LDAPSchema(); 5. ldapSchema.fetchSchema(ld); (result checking suppressed in this outline for clarity) Actual Results: java.lang.ClassCastException at netscape.ldap.LDAPMatchingRuleSchema.<init>(LDAPMatchingRuleSchema.java:223) Expected Results: No Exception should occour and the library should handle this case accordingly. I changed the source code arount line 223 223: Vector v = (Vector)properties.get( "APPLIES" ); to look like: Object p=properties.get( "APPLIES"); if(p instanceof Vector){ Vector v = (Vector)properties.get( "APPLIES" ); if ( v != null ) { attributes = new String[v.size()]; v.copyInto( attributes ); v.removeAllElements(); } } else if(p instanceof String){ attributes = new String[1]; attributes[0] = (String) p; } This works for me today, but don't know if it works with other servers.
go to parent directory of mozilla/directory... patch -p0 < vector.patch
Assignee: mcs → erhyuan
Thanks to Ingo's contribution. This is a valid bug and a good fix. Beside the LDAPMatchingRuleSchema.java, same problem also existed in LDAPMachingRuleUseSchema.java. Based on Ingo's fix, applied the same fix to both files. I also moved the JDK version from 4.17 to 4.18 for preparing next release. Could Ingo or Mark review the fix?
Based on Ingo's fix, applied to LDAPMatchingRuleUseSchema.java. The patch includes moving JDK version to 4.18.
Attachment #139988 - Attachment is obsolete: true
Comment on attachment 142003 [details] [diff] [review] New patch for fix. The fix looks good to me. I have not seen anything other than the contributor's name and email address listed in the Contributor(s) section of the copyright notice though, so maybe remove the 2nd and 3rd lines there?
Attachment #142003 - Flags: review+
Thanks for Mark's review. Updated the fix as Mark's suggestion. Committed into 4.18 developement tree. Checking in LDAPConnection.java; /cvsroot/mozilla/directory/java-sdk/ldapjdk/netscape/ldap/LDAPConnection.java,v <-- LDAPConnection.java new revision: 1.25; previous revision: 1.24 done Checking in LDAPMatchingRuleSchema.java; /cvsroot/mozilla/directory/java-sdk/ldapjdk/netscape/ldap/LDAPMatchingRuleSchema .java,v <-- LDAPMatchingRuleSchema.java new revision: 1.8; previous revision: 1.7 done Checking in LDAPMatchingRuleUseSchema.java; /cvsroot/mozilla/directory/java-sdk/ldapjdk/netscape/ldap/LDAPMatchingRuleUseSch ema.java,v <-- LDAPMatchingRuleUseSchema.java new revision: 1.2; previous revision: 1.1 done
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: