Issue Details (XML | Word | Printable)

Key: DIRSERVER-658
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Emmanuel Lecharny
Reporter: Emmanuel Lecharny
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Directory ApacheDS

ClassCast exception when fetching DNs from root DES

Created: 01/Jul/06 07:34 AM   Updated: 02/Jul/06 06:49 AM
Return to search
Component/s: None
Affects Version/s: 1.0-RC4
Fix Version/s: None

Time Tracking:
Not Specified

Resolution Date: 02/Jul/06 06:48 AM


 Description  « Hide
When fetching for DNs in LdapBrowser, you get an exception while encoding the SearchResultEntry :

...
Caused by: java.lang.ClassCastException: org.apache.directory.shared.ldap.name.LdapDN
at org.apache.directory.shared.ldap.codec.search.SearchResultEntry.computeLength(SearchResultEntry.java:240)
at org.apache.directory.shared.ldap.codec.LdapMessage.computeLength(LdapMessage.java:530)
at org.apache.directory.shared.ldap.codec.LdapMessage.encode(LdapMessage.java:602)
at org.apache.directory.shared.ldap.codec.TwixEncoder.encodeBlocking(TwixEncoder.java:121)
at org.apache.directory.shared.ldap.codec.TwixEncoder.encode(TwixEncoder.java:200)
at org.apache.directory.shared.ldap.message.MessageEncoder.encode(MessageEncoder.java:131)
at org.apache.mina.filter.codec.asn1.Asn1CodecEncoder.encode(Asn1CodecEncoder.java:55)
at org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:226)
... 22 more

The problem is that when encoding a SearchResultEntry, the values are supposed to be Strings or byte arrays, not LdapDNs. When you fetch for DNs in the root DSE, the result is stored in the SearchResultEntry as LdapDN objects, not Strings, and it's allowad, as the method which set the value accept an Object.

We have to fix two problems :
- first, check that the Object is either a String or a byte[], nothing else (defensive programming)
- second, avoid storing LdapDN objects where String or byte[] are expected :)


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #418524 Sat Jul 01 23:40:39 UTC 2006 elecharny Fixed DIRSERVER-658 : the NamingContexts are now returns as String, not as LdapDN objects.
Files Changed
MODIFY /directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/DefaultDirectoryPartitionNexus.java