[
https://issues.apache.org/jira/browse/DIRSHARED-142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13486995#comment-13486995
]
Hendy Irawan commented on DIRSHARED-142:
----------------------------------------
So the ordering is swapped between StringValue and BinaryValue's equals(). I
think this should be consistent. And this operation should be
immutable/idempotent, no modifying of any input parameters.
In StringValue, it checks the value first before checking the AT :
// First check the upValue. If they are equal, the Values are equal
if ( wrappedValue == other.wrappedValue )
{
return true;
}
else if ( wrappedValue != null )
{
if ( wrappedValue.equals( other.wrappedValue ) )
{
return true;
}
}
// If we have an attributeType, it must be equal
// We should also use the comparator if we have an AT
if ( attributeType != null )
...
But in BinaryValue, it's the other way around, it checks the AT first (which
fails), before checking the value :
// If we have an attributeType, it must be equal
// We should also use the comparator if we have an AT
if ( attributeType != null )
{
if ( other.attributeType != null )
{
if ( !attributeType.equals( other.attributeType ) )
{
return false;
}
}
else
{
other.attributeType = attributeType;
}
}
else if ( other.attributeType != null )
{
attributeType = other.attributeType;
}
// Shortcut : if the values are equals, no need to compare
// the normalized values
if ( Arrays.equals( wrappedValue, other.wrappedValue ) )
{
return true;
}
> Value<?> objects containing byte[] of same content should be equals() == true
> -----------------------------------------------------------------------------
>
> Key: DIRSHARED-142
> URL: https://issues.apache.org/jira/browse/DIRSHARED-142
> Project: Directory Shared
> Issue Type: Bug
> Affects Versions: 1.0.0-M13
> Reporter: Hendy Irawan
>
> 1. get two Attribute objects from different sources, e.g. from LDAP
> connection vs. by creating an entry programmatically
> 2. attribute1.get().equals( attribute2.get() ) will return false, which is
> wrong, because :
> Arrays.equals((byte[])attribute1.get().getNormValue(), (byte[])
> attribute2.get().getNormValue())
> will return true in this case.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira