[ 
https://issues.apache.org/jira/browse/DIRAPI-368?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17314436#comment-17314436
 ] 

Emmanuel Lécharny commented on DIRAPI-368:
------------------------------------------

Actually, I don't know why we try to keep the attributes and values ordered. 
They aren't supposed to be. We should simply iterate over the set and store 
them as is. Of course, if the entry has attributes A, B, C, then it will be 
encode with attributes C, B, A, but it's not a big deal. The very same for the 
values, which are also unordered.

OTOH, all the encoding/decoding tests are assuming values/attributes are 
ordered, which would make the modification leading to many tests modifications 
that are not really funny to implement.

All that to avoid a set reversal that is quite quick to do, even with thousands 
of elements.

Ideally speaking, what would be the best is to have a revert iterator over the 
attributes and values, but both those classes are using HashMap and 
LinkedHashSet data structure, and we don't want to rewrite those guys to be 
able to iterate in reverse order.

Your current solution fits me.

> StackOverflowError when working with entries with thousands of attributes or 
> values
> -----------------------------------------------------------------------------------
>
>                 Key: DIRAPI-368
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-368
>             Project: Directory Client API
>          Issue Type: Bug
>    Affects Versions: 2.0.1
>            Reporter: Stefan Seelmann
>            Assignee: Stefan Seelmann
>            Priority: Major
>             Fix For: 2.0.2
>
>
> Reported originally in https://issues.apache.org/jira/browse/DIRSERVER-2340
> {noformat}
> java.lang.StackOverflowError
>  at 
> org.apache.directory.api.ldap.codec.factory.SearchResultEntryFactory.encodeValues(SearchResultEntryFactory.java:66)
>  at 
> org.apache.directory.api.ldap.codec.factory.SearchResultEntryFactory.encodeValues(SearchResultEntryFactory.java:68)
>  at 
> org.apache.directory.api.ldap.codec.factory.SearchResultEntryFactory.encodeValues(SearchResultEntryFactory.java:68)
>  at 
> org.apache.directory.api.ldap.codec.factory.SearchResultEntryFactory.encodeValues(SearchResultEntryFactory.java:68)
> {noformat}
> Reason is that the encoding is done recursively.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to