You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by "Hendy Irawan (JIRA)" <ji...@apache.org> on 2012/10/30 14:36:13 UTC

[jira] [Created] (DIRSHARED-142) Value objects containing byte[] of same content should be equals() == true

Hendy Irawan created DIRSHARED-142:
--------------------------------------

             Summary: 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

[jira] [Commented] (DIRSHARED-142) Value objects containing byte[] of same content should be equals() == true

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRSHARED-142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13486926#comment-13486926 ] 

Emmanuel Lecharny commented on DIRSHARED-142:
---------------------------------------------

I'll check this part of the code, as soon as I have written the associated test. Sounds like we can improve this part, for sure.
                
> 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

[jira] [Commented] (DIRSHARED-142) Value objects containing byte[] of same content should be equals() == true

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRSHARED-142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13486874#comment-13486874 ] 

Emmanuel Lecharny commented on DIRSHARED-142:
---------------------------------------------

This is not obvious. If the attributes are SchemaAware, the test should succeed, as soon as we will use the associated MatchingRule to compare the values.

Otherwise, we need to know what are the AttributeTypes and teh value to see if this is really a problem.
                
> 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

[jira] [Commented] (DIRSHARED-142) Value objects containing byte[] of same content should be equals() == true

Posted by "Hendy Irawan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRSHARED-142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13486985#comment-13486985 ] 

Hendy Irawan commented on DIRSHARED-142:
----------------------------------------

So the question is why this only happens for userPassword and not for other attributes ?

e.g. the following returns equals() == true :

LDAP's :

{code}
ATTRIBUTE_TYPE ( 2.5.4.42
 NAME ( 'givenName' 'gn' )
 DESC RFC2256: first name(s) for which the entity is known by
 SUP name
 EQUALITY caseIgnoreMatch
 SUBSTR caseIgnoreSubstringsMatch
 SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
 USAGE userApplications
 X-SCHEMA core
 )
{code}

DefaultSchemaManager's :

{code}
ATTRIBUTE_TYPE ( 2.5.4.42
 NAME ( 'givenName' 'gn' )
 DESC RFC2256: first name(s) for which the entity is known by
 SUP name
 EQUALITY caseIgnoreMatch
 SUBSTR caseIgnoreSubstringsMatch
 SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
 USAGE userApplications
 )
{code}
                
> 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

[jira] [Commented] (DIRSHARED-142) Value objects containing byte[] of same content should be equals() == true

Posted by "Hendy Irawan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRSHARED-142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13486987#comment-13486987 ] 

Hendy Irawan commented on DIRSHARED-142:
----------------------------------------

In AttributeType.equals(), the problematic is :

        if ( !super.equals( o ) )          // this is false
        {
            return false;
        }

So probably something with AbstractSchemaObject.equals()
                
> 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

[jira] [Commented] (DIRSHARED-142) Value objects containing byte[] of same content should be equals() == true

Posted by "Hendy Irawan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRSHARED-142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13486997#comment-13486997 ] 

Hendy Irawan commented on DIRSHARED-142:
----------------------------------------

Also in BinaryValue.equals() :

        else if ( other.attributeType != null )
        {
            attributeType = other.attributeType;        // should not modify object during equals() call
        }
                
> 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

[jira] [Commented] (DIRSHARED-142) Value objects containing byte[] of same content should be equals() == true

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRSHARED-142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13487005#comment-13487005 ] 

Emmanuel Lecharny commented on DIRSHARED-142:
---------------------------------------------

You are right : the X-SCHEMA option is checked in the super class, something I have missed.

And, yes, we probably should compare the up-value first, before trying to check the normalized values, as if the up values are equals, they will be equals. Now, we must also compare the attributeType, because one could compare two values from two different attributeTypes, and even if the values are equals, they should bot be considered as if they were equal...

I have to think about the consequences of such a change, but there are things to fix, that's 100% sure ! Good catch !
                
> 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

[jira] [Commented] (DIRSHARED-142) Value objects containing byte[] of same content should be equals() == true

Posted by "Hendy Irawan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRSHARED-142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13486982#comment-13486982 ] 

Hendy Irawan commented on DIRSHARED-142:
----------------------------------------

In my case, the culprit happens on this line:

                if ( !attributeType.equals( other.attributeType ) ) // returns false here
                {
                    return false;
                }

inspecting both attributeTypes are actually this :

ATTRIBUTE_TYPE ( 2.5.4.35
 NAME 'userPassword'
 DESC RFC2256/2307: password of user
 EQUALITY octetStringMatch
 SYNTAX 1.3.6.1.4.1.1466.115.121.1.40
 USAGE userApplications
 X-SCHEMA system
 )

so something's probably wrong with AttributeType.equals() ...
                
> 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

[jira] [Resolved] (DIRSHARED-142) Value objects containing byte[] of same content should be equals() == true

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DIRSHARED-142?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Lecharny resolved DIRSHARED-142.
-----------------------------------------

    Resolution: Fixed

Fixed with http://svn.apache.org/viewvc?rev=1404693&view=rev

The logic has been completely reviewed and changed.
                
> 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

[jira] [Commented] (DIRSHARED-142) Value objects containing byte[] of same content should be equals() == true

Posted by "Hendy Irawan (JIRA)" <ji...@apache.org>.
    [ 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

[jira] [Commented] (DIRSHARED-142) Value objects containing byte[] of same content should be equals() == true

Posted by "Hendy Irawan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRSHARED-142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13489050#comment-13489050 ] 

Hendy Irawan commented on DIRSHARED-142:
----------------------------------------

Thank you Emmanuel ! :)
                
> 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

[jira] [Commented] (DIRSHARED-142) Value objects containing byte[] of same content should be equals() == true

Posted by "Hendy Irawan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRSHARED-142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13486899#comment-13486899 ] 

Hendy Irawan commented on DIRSHARED-142:
----------------------------------------

BTW I smell something in BinaryValue.equals() implementation (doesn't really solve the problem, but.. see the comment below)

{code}
        // 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; // PROBLEM: mutating the object in parameter?
            }
        }
        else if ( other.attributeType != null )
        {
            attributeType = other.attributeType;
        }
{code}

equals() should be idempotent.

                
> 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

[jira] [Comment Edited] (DIRSHARED-142) Value objects containing byte[] of same content should be equals() == true

Posted by "Hendy Irawan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRSHARED-142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13486982#comment-13486982 ] 

Hendy Irawan edited comment on DIRSHARED-142 at 10/30/12 4:18 PM:
------------------------------------------------------------------

It turns out both Value's are schema-aware.

In my case, the culprit happens on this line:

{code}
                if ( !attributeType.equals( other.attributeType ) ) // returns false here
                {
                    return false;
                }
{code}

The first attributeType (coming from LdapNetworkConnection's SchemaManager) is this :

{code}
ATTRIBUTE_TYPE ( 2.5.4.35
 NAME 'userPassword'
 DESC RFC2256/2307: password of user
 EQUALITY octetStringMatch
 SYNTAX 1.3.6.1.4.1.1466.115.121.1.40
 USAGE userApplications
 X-SCHEMA system
 )
{code}

The second attributeType, coming from new DefaultSchemaManager(), is :

{code}
ATTRIBUTE_TYPE ( 2.5.4.35
 NAME 'userPassword'
 DESC RFC2256/2307: password of user
 EQUALITY octetStringMatch
 SYNTAX 1.3.6.1.4.1.1466.115.121.1.40
 USAGE userApplications
 )
{code}

The only difference is the LDAP connection one has " X-SCHEMA system", but the rest, even the OID is the same, so I guess it should be treated the same (?).

so something's probably wrong with AttributeType.equals() ...
                
      was (Author: ceefour):
    In my case, the culprit happens on this line:

                if ( !attributeType.equals( other.attributeType ) ) // returns false here
                {
                    return false;
                }

inspecting both attributeTypes are actually this :

ATTRIBUTE_TYPE ( 2.5.4.35
 NAME 'userPassword'
 DESC RFC2256/2307: password of user
 EQUALITY octetStringMatch
 SYNTAX 1.3.6.1.4.1.1466.115.121.1.40
 USAGE userApplications
 X-SCHEMA system
 )

so something's probably wrong with AttributeType.equals() ...
                  
> 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

[jira] [Commented] (DIRSHARED-142) Value objects containing byte[] of same content should be equals() == true

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRSHARED-142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13486951#comment-13486951 ] 

Emmanuel Lecharny commented on DIRSHARED-142:
---------------------------------------------

I have added some tests :

        
        Attribute attr11 = new DefaultAttribute( atPwd, BYTES1 );
        Attribute attr12 = new DefaultAttribute( atPwd, BYTES1 );
        
        assertTrue( attr11.get().equals( attr12.get() ) );
        assertTrue( attr12.get().equals( attr11.get() ) );

        Attribute attr13 = new DefaultAttribute( "userPassword", BYTES1 );
        
        assertTrue( attr11.get().equals( attr13.get() ) );
        assertTrue( attr13.get().equals( attr11.get() ) );
        
        Attribute attr14 = new DefaultAttribute( "userPassword", BYTES1 );
        
        assertTrue( attr14.get().equals( attr13.get() ) );
        assertTrue( attr13.get().equals( attr14.get() ) );


where atPwd is an AttributeType, and BYTES1 = {0x41 0x42}. All the call to the equals() method succeed.

There must obviously be something else going wrong with the specific value you are using...
                
> 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

[jira] [Commented] (DIRSHARED-142) Value objects containing byte[] of same content should be equals() == true

Posted by "Hendy Irawan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRSHARED-142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13486992#comment-13486992 ] 

Hendy Irawan commented on DIRSHARED-142:
----------------------------------------

The StringValue.equals() check is correct because :

        // First check the upValue. If they are equal, the Values are equal
        if ( wrappedValue == other.wrappedValue )            // returns true here
        {
            return true;
        }

and the attributeType check is still below that code....
                
> 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

[jira] [Commented] (DIRSHARED-142) Value objects containing byte[] of same content should be equals() == true

Posted by "Hendy Irawan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRSHARED-142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13486892#comment-13486892 ] 

Hendy Irawan commented on DIRSHARED-142:
----------------------------------------

The Attribute from LDAP connection is from the "userPassword" attribute.

entry1 = ldapConn.lookup( .... );

The other entry can be with:

entry2.put("userPassword", byteArrayContent );

comparing entry1's userPassword .get() with entry2's userPassword .get() yields false, should be true.

The behavior is correct if the Value contains a String (regardless of schema aware), but not for byte[].
                
> 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

[jira] [Commented] (DIRSHARED-142) Value objects containing byte[] of same content should be equals() == true

Posted by "Hendy Irawan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRSHARED-142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13486989#comment-13486989 ] 

Hendy Irawan commented on DIRSHARED-142:
----------------------------------------

In AbstractSchemaObject.equals(), it fails here :

                for ( String key : extensions.keySet() )
                {
                    if ( !that.extensions.containsKey( key ) )         // returns false because 'that' doesn't contain X-SCHEMA
                    {
                        return false;
                    }

                
> 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

[jira] [Commented] (DIRSHARED-142) Value objects containing byte[] of same content should be equals() == true

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRSHARED-142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13486986#comment-13486986 ] 

Emmanuel Lecharny commented on DIRSHARED-142:
---------------------------------------------

The X-SCHEMA parameter is not used when comparing some AT. However, the comparison is also checking that the Equality MatchingRule and the Syntax are equals, too.

    /**
     * {@inheritDoc}
     */
    public boolean equals( Object o )
    {
        ...
        // The equality
        if ( !compareOid( equalityOid, that.equalityOid ) )
        {
            return false;
        }

        if ( equality != null )
        {
            if ( !equality.equals( that.equality ) )
            {
                return false;
            }
        }
        else
        {
            if ( that.equality != null )
            {
                return false;
            }
        }


        if ( syntax.equals( that.syntax ) )
        {
            return syntaxLength == that.syntaxLength;
        }
        else
        {
            return false;
        }


Here, what would help is to put a breakpoint in the equals method, and to step to know where in it the result is set to false.
                
> 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