[
https://issues.apache.org/jira/browse/DIRSTUDIO-1200?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16683050#comment-16683050
]
Emmanuel Lecharny commented on DIRSTUDIO-1200:
----------------------------------------------
It should be easy to fix the {{AttributeComparator.compare}} method. The
problem is in the two tests {{if ( value1 != null && value2 != null )}} and
{{if ( attribute1 != null && attribute2 != null )}}.
Something like that could work :
{code:java}
private IValue getValue( Object element )
{
if ( element instanceof IValue )
{
return ( IValue ) element;
}
else if ( element instanceof LdifAttrValLine )
{
return ModelConverter.ldifAttrValLineToValue( ( LdifAttrValLine )
element, dummyEntry );
}
else
{
return null;
}
}
private IAttribute getAttribute( Object element )
{
if ( element instanceof IAttribute )
{
return ( IAttribute ) element;
}
else if ( element instanceof IValue )
{
return ( ( IValue ) element ).getAttribute();
}
else if ( element instanceof LdifAttrValLine )
{
LdifAttrValLine line1 = ( LdifAttrValLine ) element;
IValue value = ModelConverter.ldifAttrValLineToValue( line1,
dummyEntry );
return value.getAttribute();
}
else
{
return null;
}
}
private int compare( IValue value1, IValue value2 )
{
if ( this.getSortByOrDefault() ==
BrowserCoreConstants.SORT_BY_ATTRIBUTE_DESCRIPTION )
{
if ( value1.getAttribute() != value2.getAttribute() )
{
return this.compareAttributeNames( value1.getAttribute(),
value2.getAttribute() );
}
else
{
return this.compareValues( value1, value2 );
}
}
else if ( this.getSortByOrDefault() ==
BrowserCoreConstants.SORT_BY_VALUE )
{
return this.compareValues( value1, value2 );
}
else
{
return this.equal();
}
}
@Override
public int compare( Object o1, Object o2 )
{
IAttribute attribute1 = getAttribute( o1 );
IValue value1 = getValue( o1);
IAttribute attribute2 = getAttribute( o2 );
IValue value2 = getValue( o2 );
if ( value1 != null )
{
if ( value2 == null )
{
return greaterThan();
}
else
{
return compare( value1, value2 );
}
}
else if ( value2 != null )
{
return lessThan();
}
if ( attribute1 != null )
{
if ( attribute2 == null )
{
return greaterThan();
}
else
{
return compareAttributeNames( attribute1, attribute2 );
}
}
else if ( attribute2 != null )
{
return lessThan();
}
else
{
return equal();
}
}
{code}
> LDIF export fails with "Comparison method violates its general contract!"
> -------------------------------------------------------------------------
>
> Key: DIRSTUDIO-1200
> URL: https://issues.apache.org/jira/browse/DIRSTUDIO-1200
> Project: Directory Studio
> Issue Type: Bug
> Components: studio-apacheds
> Affects Versions: 2.0.0-M14
> Environment: LDAP source: eDirectory 9.0.4 running on RHEL 7
> Client: Windows 10 VM with 8GB of RAM and two VCPUs
> Reporter: Douglas
> Priority: Major
>
> When attempting to perform an LDIF export of an eDirectory tree using
> Directory Studio,the operation fails with "Comparison method violates its
> general contract!". More information:
> java.lang.IllegalArgumentException: Comparison method violates its general
> contract!
> > at java.util.TimSort.mergeHi(Unknown Source)
> > at java.util.TimSort.mergeAt(Unknown Source)
> > at java.util.TimSort.mergeCollapse(Unknown Source)
> > at java.util.TimSort.sort(Unknown Source)
> > at java.util.Arrays.sort(Unknown Source)
> > at
> org.apache.directory.studio.ldapbrowser.core.jobs.ExportLdifRunnable.export(https://urldefense.proofpoint.com/v2/url?u=http-3A__ExportLdifRunnable.java&d=DwIDaQ&c=k9MF1d71ITtkuJx-PdWme51dKbmfPEvxwt8SFEkBfs4&r=9lyckcM6ZhJLsBO8S-PrSIMUchQ_vFPG0h87-ifHH1k&m=JgmgAeyDkIx7WxLqzVCpQOm6lbwj08yM8r5umx2lbyw&s=rYuqOHlWSBH6Wm9O3M5GsiMVJf3KWomwxHEGTr0aohc&e=:205)
> > at
> org.apache.directory.studio.ldapbrowser.core.jobs.ExportLdifRunnable.run(https://urldefense.proofpoint.com/v2/url?u=http-3A__ExportLdifRunnable.java&d=DwIDaQ&c=k9MF1d71ITtkuJx-PdWme51dKbmfPEvxwt8SFEkBfs4&r=9lyckcM6ZhJLsBO8S-PrSIMUchQ_vFPG0h87-ifHH1k&m=JgmgAeyDkIx7WxLqzVCpQOm6lbwj08yM8r5umx2lbyw&s=rYuqOHlWSBH6Wm9O3M5GsiMVJf3KWomwxHEGTr0aohc&e=:156)
> > at
> org.apache.directory.studio.connection.core.jobs.StudioConnectionJob.run(https://urldefense.proofpoint.com/v2/url?u=http-3A__StudioConnectionJob.java&d=DwIDaQ&c=k9MF1d71ITtkuJx-PdWme51dKbmfPEvxwt8SFEkBfs4&r=9lyckcM6ZhJLsBO8S-PrSIMUchQ_vFPG0h87-ifHH1k&m=JgmgAeyDkIx7WxLqzVCpQOm6lbwj08yM8r5umx2lbyw&s=nDAeT-69RWJRooKBVD54L1v9VphxNj91vZJjfFyhiO0&e=:119)
> > at
> org.eclipse.core.internal.jobs.Worker.run([https://urldefense.proofpoint.com/v2/url?u=http-3A__Worker.java&d=DwIDaQ&c=k9MF1d71ITtkuJx-PdWme51dKbmfPEvxwt8SFEkBfs4&r=9lyckcM6ZhJLsBO8S-PrSIMUchQ_vFPG0h87-ifHH1k&m=JgmgAeyDkIx7WxLqzVCpQOm6lbwj08yM8r5umx2lbyw&s=tcHoNZQdhA3l9xk6yQcxRMXUqWZopZipfIpiFW9a43c&e=:60)]
>
> Stefan Seelmann requested I file this bug report.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)