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

Maruan Sahyoun commented on PDFBOX-4669:
----------------------------------------

After implementing {{equals}} and {{hashCode}} for {{COSArray}} and 
{{COSDictionary}} the {{removeAll}} method works as expected i.e. similar to 
java.util.List for both the PDAnnotations list as well as the underlying 
COSArray. Unfortunately there is now one failing unit test 
{{PDFMergerUtilityTest.testPDFMergerOpenAction}} all other tests pass. Need to 
look into more details why this is happening. After resolving that I can commit 
the changes.

BTW it's the custom implementation of the equals method which is causing that 
test to fail so I'm posting it here for reference:
{code:java}
public boolean equals(Object o) {
    if (o == this)
    {
        return true;
    }

    if (!(o instanceof COSDictionary))
    {
        return false;
    }

    COSDictionary toBeCompared = (COSDictionary) o;

    if (toBeCompared.size() != size())
    {
        return false;
    }

    Iterator<Entry<COSName, COSBase>> iter = entrySet().iterator();
    while (iter.hasNext())
    {
        Entry<COSName, COSBase> entry = iter.next();
        COSName key = entry.getKey();
        COSBase value = entry.getValue();

        if (value == null && !(toBeCompared.getItem(key) == null && 
toBeCompared.containsKey(key)))
        {
            return false;
        }
        else if (!value.equals(toBeCompared.getItem(key)))
        {
            return false;
        }
    }

    return true;
}
{code}

> Ensure proper functionality of COSArrayList
> -------------------------------------------
>
>                 Key: PDFBOX-4669
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4669
>             Project: PDFBox
>          Issue Type: Sub-task
>          Components: PDModel
>    Affects Versions: 2.0.17, 3.0.0 PDFBox
>            Reporter: Maruan Sahyoun
>            Assignee: Maruan Sahyoun
>            Priority: Major
>
> The current COSArrayList implementation has some glitches as pointed out at 
> https://stackoverflow.com/questions/45812696/
> In addition when working with {{AnnotationFilter}} as the 
> adding/update/removal is index based the wron index of the underlying 
> {{COSArray}} is affected. 



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